r61395 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61394‎ | r61395 | r61396 >
Date:21:23, 22 January 2010
Author:btongminh
Status:ok
Tags:
Comment:
(bug 22228) SQL error of Global Usage when image page without associated image is deleted

Fixed by moving the copyLocalimagelinks call from onArticleDeleteComplete to onFileDeleteComplete.
Modified paths:
  • /trunk/extensions/GlobalUsage/GlobalUsage.php (modified) (history)
  • /trunk/extensions/GlobalUsage/GlobalUsageHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalUsage/GlobalUsageHooks.php
@@ -55,14 +55,22 @@
5656 /**
5757 * Hook to ArticleDeleteComplete
5858 * Deletes entries from usage table.
59 - * In case of an image, copies the local link table to the global.
6059 */
6160 public static function onArticleDeleteComplete( $article, $user, $reason, $id ) {
6261 $title = $article->getTitle();
6362 $gu = self::getGlobalUsage();
6463 $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() );
6775 }
6876 return true;
6977 }
Index: trunk/extensions/GlobalUsage/GlobalUsage.php
@@ -65,6 +65,7 @@
6666 */
6767 $wgHooks['LinksUpdateComplete'][] = 'GlobalUsageHooks::onLinksUpdateComplete';
6868 $wgHooks['ArticleDeleteComplete'][] = 'GlobalUsageHooks::onArticleDeleteComplete';
 69+$wgHooks['FileDeleteComplete'][] = 'GlobalUsageHooks::onFileDeleteComplete';
6970 $wgHooks['FileUndeleteComplete'][] = 'GlobalUsageHooks::onFileUndeleteComplete';
7071 $wgHooks['UploadComplete'][] = 'GlobalUsageHooks::onUploadComplete';
7172 $wgHooks['TitleMoveComplete'][] = 'GlobalUsageHooks::onTitleMoveComplete';

Follow-up revisions

RevisionCommit summaryAuthorDate
r61534wmf-deployment: Merge r61395 (GlobalUsage SQL error fix) from trunkcatrope20:28, 26 January 2010

Status & tagging log