r96905 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96904‎ | r96905 | r96906 >
Date:21:14, 12 September 2011
Author:catrope
Status:ok
Tags:
Comment:
RL2: Clean up more duplication in GadgetHooks
Modified paths:
  • /branches/RL2/extensions/Gadgets/GadgetHooks.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/GadgetHooks.php
@@ -84,17 +84,16 @@
8585
8686 return true;
8787 }
88 -
 88+
8989 /**
90 - * ArticleUndelete hook handler
 90+ * Update the database entry for a gadget if the description page is
 91+ * newer than the database entry.
9192 * @param $title Title object
92 - * @param $created Bool: Whether this undeletion recreated the page
93 - * @param $comment String: Undeletion summary
9493 */
95 - public static function gadgetDefinitionUndelete( $title, $created, $comment ) {
 94+ public static function gadgetDefinitionUpdateIfChanged( $title ) {
9695 $id = self::getIDFromTitle( $title );
9796 if ( !$id ) {
98 - return true;
 97+ return;
9998 }
10099
101100 // Check whether this undeletion changed the latest revision of the page, by comparing
@@ -107,7 +106,7 @@
108107 if ( wfTimestamp( TS_MW, $rev->getTimestamp() ) ===
109108 wfTimestamp( TS_MW, $gadgetTS ) ) {
110109 // The latest rev didn't change. Someone must've undeleted an older revision
111 - return true;
 110+ return;
112111 }
113112
114113 // Update the database entry for this gadget
@@ -116,14 +115,22 @@
117116
118117 // modifyGadget() returns a Status object with an error if there was a conflict,
119118 // but we do't care, see similar comment in articleSaveComplete()
 119+ return;
 120+ }
 121+
 122+ /**
 123+ * ArticleUndelete hook handler
 124+ * @param $title Title object
 125+ * @param $created Bool: Whether this undeletion recreated the page
 126+ * @param $comment String: Undeletion summary
 127+ */
 128+ public static function gadgetDefinitionUndelete( $title, $created, $comment ) {
 129+ self::gadgetDefinitionUpdateIfChanged( $title );
120130 return true;
121131 }
122132
123133 public static function gadgetDefinitionImport( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) {
124 - // HACK: AAAAAAARGH. Should fix this duplication properly
125 - // Logic is the same as in gadgetDefinitionUndelete() and that function only uses the $title parameter
126 - // Shit, shit, shit, this is ugly
127 - self::gadgetDefinitionUndelete( $title, true, '' );
 134+ self::gadgetDefinitionUpdateIfChanged( $title );
128135 return true;
129136 }
130137

Status & tagging log