Index: trunk/extensions/GlobalUsage/SpecialGlobalUsage.php |
— | — | @@ -228,10 +228,23 @@ |
229 | 229 | * @return bool |
230 | 230 | */ |
231 | 231 | protected static function hasResults( $imagePage ) { |
| 232 | + # Don't display links if the target file does not exist |
232 | 233 | $file = $imagePage->getFile(); |
233 | | - if ( !$file->exists() || $file->getRepoName() == 'local' ) |
| 234 | + if ( !$file->exists() ) { |
234 | 235 | return false; |
| 236 | + } |
235 | 237 | |
| 238 | + # Don't show global usage if the file is local. |
| 239 | + # Do show it however if the current repo is the shared repo. The way |
| 240 | + # we detect this is a bit hacky and less than ideal. See bug 23136 for |
| 241 | + # a discussion. |
| 242 | + global $wgGlobalUsageDatabase; |
| 243 | + $dbr = wfGetDB( DB_SLAVE ); |
| 244 | + if ( $file->getRepoName() == 'local' |
| 245 | + && $dbr->getDBname() != $wgGlobalUsageDatabase ) { |
| 246 | + return false; |
| 247 | + } |
| 248 | + |
236 | 249 | $query = self::getImagePageQuery( $imagePage->getFile()->getTitle() ); |
237 | 250 | return (bool)$query->getResult(); |
238 | 251 | } |