This is easier to maintain as duplicated code everywhere.
This change also adds LinkBatch operations to specialpages, that does
not had it so far, but where it's useful.
Change-Id: I4936ecfb2be3a7709d99570c0561ab0cc9cd754f
* @param ResultWrapper $res
*/
public function preprocessResults( $db, $res ) {
- if ( !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch();
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
-
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
/**
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 );
+ }
}
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- if ( !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch;
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
-
- // Back to start for display
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
/**
return false;
}
+ public function preprocessResults( $db, $res ) {
+ $this->executeLBFromResultWrapper( $res );
+ }
+
/**
* @param Skin $skin
* @param object $result Result row
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- if ( !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch;
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
-
- // Back to start for display
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
protected function getGroupName() {
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- if ( $res->numRows() > 0 ) {
- $linkBatch = new LinkBatch();
-
- foreach ( $res as $row ) {
- $linkBatch->add( $row->namespace, $row->title );
- }
-
- $res->seek( 0 );
- $linkBatch->execute();
- }
+ $this->executeLBFromResultWrapper( $res );
}
/**
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- if ( $res->numRows() > 0 ) {
- $linkBatch = new LinkBatch();
-
- foreach ( $res as $row ) {
- $linkBatch->add( $row->namespace, $row->title );
- }
-
- $res->seek( 0 );
- $linkBatch->execute();
- }
+ $this->executeLBFromResultWrapper( $res );
}
/**
return in_array( $type, $types );
}
+ public function preprocessResults( $db, $res ) {
+ $this->executeLBFromResultWrapper( $res );
+ }
+
protected function getGroupName() {
return 'media';
}
* @param ResultWrapper $res
*/
public function preprocessResults( $dbr, $res ) {
+ $this->executeLBFromResultWrapper( $res );
$this->totalCount = $this->totalBytes = 0;
foreach ( $res as $row ) {
$mediaStats = $this->splitFakeTitle( $row->title );
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- # There's no point doing a batch check if we aren't caching results;
- # the page must exist for it to have been pulled out of the table
- if ( !$this->isCached() || !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch();
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
-
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
/**
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- # There's no point doing a batch check if we aren't caching results;
- # the page must exist for it to have been pulled out of the table
- if ( !$this->isCached() || !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch;
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
-
- // Back to start for display
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
/**
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- if ( $res->numRows() > 0 ) {
- $linkBatch = new LinkBatch();
-
- foreach ( $res as $row ) {
- $linkBatch->add( $row->namespace, $row->title );
- }
-
- $res->seek( 0 );
- $linkBatch->execute();
- }
+ $this->executeLBFromResultWrapper( $res );
}
/**
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- if ( !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch;
- foreach ( $res as $row ) {
- $batch->add( NS_CATEGORY, $row->title );
- }
- $batch->execute();
-
- // Back to start for display
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
/**
* @param ResultWrapper $res
*/
public function preprocessResults( $db, $res ) {
- if ( !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch();
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
-
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
/**
* @param ResultWrapper $res
*/
function preprocessResults( $db, $res ) {
- # There's no point doing a batch check if we aren't caching results;
- # the page must exist for it to have been pulled out of the table
- if ( !$this->isCached() || !$res->numRows() ) {
- return;
- }
-
- $batch = new LinkBatch();
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
-
- $res->seek( 0 );
+ $this->executeLBFromResultWrapper( $res );
}
function sortDescending() {
protected function getGroupName() {
return 'maintenance';
}
+
+ public function preprocessResults( $db, $res ) {
+ $this->executeLBFromResultWrapper( $res );
+ }
}