X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialDoubleRedirects.php;h=77c59f03878505df45c58af86bf59884d591b227;hb=25d84b8da85e963a3126d0e996c1ce1aa14581b2;hp=d7e99db817ac7cb95d05b849a11911071f6e701b;hpb=bf9c2b0cb30cbe994f3a1859cf46224dd52039e1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialDoubleRedirects.php b/includes/specials/SpecialDoubleRedirects.php index d7e99db817..77c59f0387 100644 --- a/includes/specials/SpecialDoubleRedirects.php +++ b/includes/specials/SpecialDoubleRedirects.php @@ -21,7 +21,7 @@ * @ingroup SpecialPage */ -use Wikimedia\Rdbms\ResultWrapper; +use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\Rdbms\IDatabase; /** @@ -66,14 +66,15 @@ class DoubleRedirectsPage extends QueryPage { 'title' => 'pa.page_title', 'value' => 'pa.page_title', - 'nsb' => 'pb.page_namespace', - 'tb' => 'pb.page_title', + 'b_namespace' => 'pb.page_namespace', + 'b_title' => 'pb.page_title', // Select fields from redirect instead of page. Because there may // not actually be a page table row for this target (e.g. for interwiki redirects) - 'nsc' => 'rb.rd_namespace', - 'tc' => 'rb.rd_title', - 'iwc' => 'rb.rd_interwiki', + 'c_namespace' => 'rb.rd_namespace', + 'c_title' => 'rb.rd_title', + 'c_fragment' => 'rb.rd_fragment', + 'c_interwiki' => 'rb.rd_interwiki', ], 'conds' => [ 'ra.rd_from = pa.page_id', @@ -116,45 +117,41 @@ class DoubleRedirectsPage extends QueryPage { * @return string */ function formatResult( $skin, $result ) { - $titleA = Title::makeTitle( $result->namespace, $result->title ); - - // If only titleA is in the query, it means this came from - // querycache (which only saves 3 columns). + // If no Title B or C is in the query, it means this came from + // querycache (which only saves the 3 columns for title A). // That does save the bulk of the query cost, but now we need to // get a little more detail about each individual entry quickly // using the filter of reallyGetQueryInfo. - if ( $result && !isset( $result->nsb ) ) { - $dbr = wfGetDB( DB_REPLICA ); - $qi = $this->reallyGetQueryInfo( - $result->namespace, - $result->title - ); - $res = $dbr->select( - $qi['tables'], - $qi['fields'], - $qi['conds'], - __METHOD__ - ); - - if ( $res ) { - $result = $dbr->fetchObject( $res ); + $deep = false; + if ( $result ) { + if ( isset( $result->b_namespace ) ) { + $deep = $result; + } else { + $dbr = wfGetDB( DB_REPLICA ); + $qi = $this->reallyGetQueryInfo( + $result->namespace, + $result->title + ); + $res = $dbr->select( + $qi['tables'], + $qi['fields'], + $qi['conds'], + __METHOD__ + ); + + if ( $res ) { + $deep = $dbr->fetchObject( $res ) ?: false; + } } } + + $titleA = Title::makeTitle( $result->namespace, $result->title ); + $linkRenderer = $this->getLinkRenderer(); - if ( !$result ) { + if ( !$deep ) { return '' . $linkRenderer->makeLink( $titleA, null, [], [ 'redirect' => 'no' ] ) . ''; } - $titleB = Title::makeTitle( $result->nsb, $result->tb ); - $titleC = Title::makeTitle( $result->nsc, $result->tc, '', $result->iwc ); - - $linkA = $linkRenderer->makeKnownLink( - $titleA, - null, - [], - [ 'redirect' => 'no' ] - ); - // if the page is editable, add an edit link if ( // check user permissions @@ -172,6 +169,14 @@ class DoubleRedirectsPage extends QueryPage { $edit = ''; } + $linkA = $linkRenderer->makeKnownLink( + $titleA, + null, + [], + [ 'redirect' => 'no' ] + ); + + $titleB = Title::makeTitle( $deep->b_namespace, $deep->b_title ); $linkB = $linkRenderer->makeKnownLink( $titleB, null, @@ -179,7 +184,13 @@ class DoubleRedirectsPage extends QueryPage { [ 'redirect' => 'no' ] ); - $linkC = $linkRenderer->makeKnownLink( $titleC ); + $titleC = Title::makeTitle( + $deep->c_namespace, + $deep->c_title, + $deep->c_fragment, + $deep->c_interwiki + ); + $linkC = $linkRenderer->makeKnownLink( $titleC, $titleC->getFullText() ); $lang = $this->getLanguage(); $arr = $lang->getArrow() . $lang->getDirMark(); @@ -191,7 +202,7 @@ class DoubleRedirectsPage extends QueryPage { * Cache page content model and gender distinction for performance * * @param IDatabase $db - * @param ResultWrapper $res + * @param IResultWrapper $res */ function preprocessResults( $db, $res ) { if ( !$res->numRows() ) { @@ -201,13 +212,13 @@ class DoubleRedirectsPage extends QueryPage { $batch = new LinkBatch; foreach ( $res as $row ) { $batch->add( $row->namespace, $row->title ); - if ( isset( $row->nsb ) ) { + if ( isset( $row->b_namespace ) ) { // lazy loaded when using cached results - $batch->add( $row->nsb, $row->tb ); + $batch->add( $row->b_namespace, $row->b_title ); } - if ( isset( $row->iwc ) && !$row->iwc ) { + if ( isset( $row->c_interwiki ) && !$row->c_interwiki ) { // lazy loaded when using cached result, not added when interwiki link - $batch->add( $row->nsc, $row->tc ); + $batch->add( $row->c_namespace, $row->c_title ); } } $batch->execute();