X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecialpage%2FQueryPage.php;h=359250005574ac467b6048397b7a596601f33c2a;hp=1beac43079f0bd884a942418d9fe07615c2bef2e;hb=e758226c91935a1df2b6fd3ed1f18922d8bfb45b;hpb=500889f19005b4aed93c5b6eaafd35689fce7dcd diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index 1beac43079..3592500055 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -376,7 +376,7 @@ abstract class QueryPage extends SpecialPage { * @return IDatabase */ function getRecacheDB() { - return wfGetDB( DB_SLAVE, [ $this->getName(), 'QueryPage::recache', 'vslow' ] ); + return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] ); } /** @@ -453,7 +453,7 @@ abstract class QueryPage extends SpecialPage { * @since 1.18 */ public function fetchFromCache( $limit, $offset = false ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $options = []; if ( $limit !== false ) { $options['LIMIT'] = intval( $limit ); @@ -477,7 +477,7 @@ abstract class QueryPage extends SpecialPage { public function getCachedTimestamp() { if ( is_null( $this->cachedTimestamp ) ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $fname = get_class( $this ) . '::getCachedTimestamp'; $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp', [ 'qci_type' => $this->getName() ], $fname ); @@ -825,4 +825,28 @@ abstract class QueryPage extends SpecialPage { function feedUrl() { return $this->getPageTitle()->getFullURL(); } + + /** + * Creates a new LinkBatch object, adds all pages from the passed ResultWrapper (MUST include + * title and optional the namespace field) and executes the batch. This operation will pre-cache + * LinkCache information like page existence and information for stub color and redirect hints. + * + * @param ResultWrapper $res The ResultWrapper object to process. Needs to include the title + * field and namespace field, if the $ns parameter isn't set. + * @param null $ns Use this namespace for the given titles in the ResultWrapper object, + * instead of the namespace value of $res. + */ + protected function executeLBFromResultWrapper( ResultWrapper $res, $ns = null ) { + if ( !$res->numRows() ) { + return; + } + + $batch = new LinkBatch; + foreach ( $res as $row ) { + $batch->add( $ns !== null ? $ns : $row->namespace, $row->title ); + } + $batch->execute(); + + $res->seek( 0 ); + } }