r99284 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99283‎ | r99284 | r99285 >
Date:00:04, 8 October 2011
Author:aaron
Status:ok
Tags:
Comment:
MFT r99283 - Fixed query for when a file Title is given (use the dbkey not the toString() conversion).
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/GlobalUsage/GlobalUsageQuery.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/GlobalUsage/GlobalUsageQuery.php
@@ -12,7 +12,7 @@
1313 private $reversed = false;
1414
1515 /**
16 - * @param $target mixed Title or db key, or array of db keys of target(s).
 16+ * @param $target mixed Title or array of db keys of target(s).
1717 * If a title, can be a category or a file
1818 */
1919 public function __construct( $target ) {
@@ -110,20 +110,22 @@
111111 $tables = array( 'globalimagelinks' );
112112
113113 // Add target image(s)
114 - if ( is_array( $this->target ) ) {
 114+ if ( is_array( $this->target ) ) { // array of dbkey strings
115115 $namespace = NS_FILE;
116 - } else {
 116+ $queryIn = $this->target;
 117+ } else { // a Title object
117118 $namespace = $this->target->getNamespace();
 119+ $queryIn = $this->target->getDbKey();
118120 }
119121 switch ( $namespace ) {
120122 case NS_FILE:
121 - $where = array( 'gil_to' => $this->target );
 123+ $where = array( 'gil_to' => $queryIn );
122124 break;
123125 case NS_CATEGORY:
124126 $tables[] = 'categorylinks';
125127 $tables[] = 'page';
126128 $where = array(
127 - 'cl_to' => $this->target->getDbKey(),
 129+ 'cl_to' => $queryIn,
128130 'cl_from = page_id',
129131 'page_namespace = ' . NS_FILE,
130132 'gil_to = page_title',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99283Fixed query for when a file Title is given (use the dbkey not the toString() ...aaron00:03, 8 October 2011

Status & tagging log