r99283 MediaWiki - Code Review archive

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

Diff [purge]

Index: trunk/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 ) {
@@ -113,20 +113,22 @@
114114 $tables = array( 'globalimagelinks' );
115115
116116 // Add target image(s)
117 - if ( is_array( $this->target ) ) {
 117+ if ( is_array( $this->target ) ) { // array of dbkey strings
118118 $namespace = NS_FILE;
119 - } else {
 119+ $queryIn = $this->target;
 120+ } else { // a Title object
120121 $namespace = $this->target->getNamespace();
 122+ $queryIn = $this->target->getDbKey();
121123 }
122124 switch ( $namespace ) {
123125 case NS_FILE:
124 - $where = array( 'gil_to' => $this->target );
 126+ $where = array( 'gil_to' => $queryIn );
125127 break;
126128 case NS_CATEGORY:
127129 $tables[] = 'categorylinks';
128130 $tables[] = 'page';
129131 $where = array(
130 - 'cl_to' => $this->target->getDbKey(),
 132+ 'cl_to' => $queryIn,
131133 'cl_from = page_id',
132134 'page_namespace = ' . NS_FILE,
133135 'gil_to = page_title',

Follow-up revisions

RevisionCommit summaryAuthorDate
r99284MFT r99283 - Fixed query for when a file Title is given (use the dbkey not th...aaron00:04, 8 October 2011

Comments

#Comment by G.Hagedorn (talk | contribs)   13:32, 9 October 2011

Please apply to 1.18 as well; GlobalUsage seems to be broken in 1.18 (reported as bug 30571). I wonder whether this might fix it.

Status & tagging log