Index: trunk/extensions/GlobalUsage/GlobalUsageHooks.php |
— | — | @@ -55,14 +55,22 @@ |
56 | 56 | /** |
57 | 57 | * Hook to ArticleDeleteComplete |
58 | 58 | * Deletes entries from usage table. |
59 | | - * In case of an image, copies the local link table to the global. |
60 | 59 | */ |
61 | 60 | public static function onArticleDeleteComplete( $article, $user, $reason, $id ) { |
62 | 61 | $title = $article->getTitle(); |
63 | 62 | $gu = self::getGlobalUsage(); |
64 | 63 | $gu->deleteLinksFromPage( $id ); |
65 | | - if ( $title->getNamespace() == NS_FILE ) { |
66 | | - $gu->copyLocalImagelinks( $title ); |
| 64 | + |
| 65 | + return true; |
| 66 | + } |
| 67 | + /** |
| 68 | + * Hook to FileDeleteComplete |
| 69 | + * Copies the local link table to the global. |
| 70 | + */ |
| 71 | + public static function onFileDeleteComplete( $file, $oldimage, $article, $wgUser, $reason ) { |
| 72 | + if ( !$oldimage ) { |
| 73 | + $gu = self::getGlobalUsage(); |
| 74 | + $gu->copyLocalImagelinks( $file->getTitle() ); |
67 | 75 | } |
68 | 76 | return true; |
69 | 77 | } |
Index: trunk/extensions/GlobalUsage/GlobalUsage.php |
— | — | @@ -65,6 +65,7 @@ |
66 | 66 | */ |
67 | 67 | $wgHooks['LinksUpdateComplete'][] = 'GlobalUsageHooks::onLinksUpdateComplete'; |
68 | 68 | $wgHooks['ArticleDeleteComplete'][] = 'GlobalUsageHooks::onArticleDeleteComplete'; |
| 69 | +$wgHooks['FileDeleteComplete'][] = 'GlobalUsageHooks::onFileDeleteComplete'; |
69 | 70 | $wgHooks['FileUndeleteComplete'][] = 'GlobalUsageHooks::onFileUndeleteComplete'; |
70 | 71 | $wgHooks['UploadComplete'][] = 'GlobalUsageHooks::onUploadComplete'; |
71 | 72 | $wgHooks['TitleMoveComplete'][] = 'GlobalUsageHooks::onTitleMoveComplete'; |