summaryrefslogtreecommitdiff
path: root/includes/cache/LinkBatch.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/cache/LinkBatch.php')
-rw-r--r--includes/cache/LinkBatch.php47
1 files changed, 29 insertions, 18 deletions
diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php
index 48b60aa9..48c063f4 100644
--- a/includes/cache/LinkBatch.php
+++ b/includes/cache/LinkBatch.php
@@ -31,7 +31,7 @@ class LinkBatch {
/**
* 2-d array, first index namespace, second index dbkey, value arbitrary
*/
- var $data = array();
+ public $data = array();
/**
* For debugging which method is using this class.
@@ -49,14 +49,14 @@ class LinkBatch {
* class. Only used in debugging output.
* @since 1.17
*
- * @param $caller
+ * @param string $caller
*/
public function setCaller( $caller ) {
$this->caller = $caller;
}
/**
- * @param $title Title
+ * @param Title $title
*/
public function addObj( $title ) {
if ( is_object( $title ) ) {
@@ -67,9 +67,8 @@ class LinkBatch {
}
/**
- * @param $ns int
- * @param $dbkey string
- * @return mixed
+ * @param int $ns
+ * @param string $dbkey
*/
public function add( $ns, $dbkey ) {
if ( $ns < 0 ) {
@@ -86,7 +85,7 @@ class LinkBatch {
* Set the link list to a given 2-d array
* First key is the namespace, second is the DB key, value arbitrary
*
- * @param $array array
+ * @param array $array
*/
public function setArray( $array ) {
$this->data = $array;
@@ -113,10 +112,11 @@ class LinkBatch {
/**
* Do the query and add the results to the LinkCache object
*
- * @return Array mapping PDBK to ID
+ * @return array Mapping PDBK to ID
*/
public function execute() {
$linkCache = LinkCache::singleton();
+
return $this->executeInto( $linkCache );
}
@@ -124,8 +124,8 @@ class LinkBatch {
* Do the query and add the results to a given LinkCache object
* Return an array mapping PDBK to ID
*
- * @param $cache LinkCache
- * @return Array remaining IDs
+ * @param LinkCache $cache
+ * @return array Remaining IDs
*/
protected function executeInto( &$cache ) {
wfProfileIn( __METHOD__ );
@@ -133,6 +133,7 @@ class LinkBatch {
$this->doGenderQuery();
$ids = $this->addResultToCache( $cache, $res );
wfProfileOut( __METHOD__ );
+
return $ids;
}
@@ -142,9 +143,9 @@ class LinkBatch {
* This function *also* stores extra fields of the title used for link
* parsing to avoid extra DB queries.
*
- * @param $cache LinkCache
- * @param $res
- * @return Array of remaining titles
+ * @param LinkCache $cache
+ * @param ResultWrapper $res
+ * @return array Array of remaining titles
*/
public function addResultToCache( $cache, $res ) {
if ( !$res ) {
@@ -170,14 +171,17 @@ class LinkBatch {
$ids[$title->getPrefixedDBkey()] = 0;
}
}
+
return $ids;
}
/**
* Perform the existence test query, return a ResultWrapper with page_id fields
- * @return Bool|ResultWrapper
+ * @return bool|ResultWrapper
*/
public function doQuery() {
+ global $wgContentHandlerUseDB;
+
if ( $this->isEmpty() ) {
return false;
}
@@ -188,6 +192,11 @@ class LinkBatch {
$table = 'page';
$fields = array( 'page_id', 'page_namespace', 'page_title', 'page_len',
'page_is_redirect', 'page_latest' );
+
+ if ( $wgContentHandlerUseDB ) {
+ $fields[] = 'page_content_model';
+ }
+
$conds = $this->constructSet( 'page', $dbr );
// Do query
@@ -197,13 +206,14 @@ class LinkBatch {
}
$res = $dbr->select( $table, $fields, $conds, $caller );
wfProfileOut( __METHOD__ );
+
return $res;
}
/**
* Do (and cache) {{GENDER:...}} information for userpages in this LinkBatch
*
- * @return bool whether the query was successful
+ * @return bool Whether the query was successful
*/
public function doGenderQuery() {
if ( $this->isEmpty() ) {
@@ -217,15 +227,16 @@ class LinkBatch {
$genderCache = GenderCache::singleton();
$genderCache->doLinkBatch( $this->data, $this->caller );
+
return true;
}
/**
* Construct a WHERE clause which will match all the given titles.
*
- * @param string $prefix the appropriate table's field name prefix ('page', 'pl', etc)
- * @param $db DatabaseBase object to use
- * @return mixed string with SQL where clause fragment, or false if no items.
+ * @param string $prefix The appropriate table's field name prefix ('page', 'pl', etc)
+ * @param DatabaseBase $db DatabaseBase object to use
+ * @return string|bool String with SQL where clause fragment, or false if no items.
*/
public function constructSet( $prefix, $db ) {
return $db->makeWhereFrom2d( $this->data, "{$prefix}_namespace", "{$prefix}_title" );