Index: branches/wmf/1.18wmf1/extensions/GlobalUsage/GlobalUsageQuery.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | private $reversed = false; |
14 | 14 | |
15 | 15 | /** |
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). |
17 | 17 | * If a title, can be a category or a file |
18 | 18 | */ |
19 | 19 | public function __construct( $target ) { |
— | — | @@ -110,20 +110,22 @@ |
111 | 111 | $tables = array( 'globalimagelinks' ); |
112 | 112 | |
113 | 113 | // Add target image(s) |
114 | | - if ( is_array( $this->target ) ) { |
| 114 | + if ( is_array( $this->target ) ) { // array of dbkey strings |
115 | 115 | $namespace = NS_FILE; |
116 | | - } else { |
| 116 | + $queryIn = $this->target; |
| 117 | + } else { // a Title object |
117 | 118 | $namespace = $this->target->getNamespace(); |
| 119 | + $queryIn = $this->target->getDbKey(); |
118 | 120 | } |
119 | 121 | switch ( $namespace ) { |
120 | 122 | case NS_FILE: |
121 | | - $where = array( 'gil_to' => $this->target ); |
| 123 | + $where = array( 'gil_to' => $queryIn ); |
122 | 124 | break; |
123 | 125 | case NS_CATEGORY: |
124 | 126 | $tables[] = 'categorylinks'; |
125 | 127 | $tables[] = 'page'; |
126 | 128 | $where = array( |
127 | | - 'cl_to' => $this->target->getDbKey(), |
| 129 | + 'cl_to' => $queryIn, |
128 | 130 | 'cl_from = page_id', |
129 | 131 | 'page_namespace = ' . NS_FILE, |
130 | 132 | 'gil_to = page_title', |