Index: branches/RL2/extensions/Gadgets/GadgetHooks.php |
— | — | @@ -84,17 +84,16 @@ |
85 | 85 | |
86 | 86 | return true; |
87 | 87 | } |
88 | | - |
| 88 | + |
89 | 89 | /** |
90 | | - * ArticleUndelete hook handler |
| 90 | + * Update the database entry for a gadget if the description page is |
| 91 | + * newer than the database entry. |
91 | 92 | * @param $title Title object |
92 | | - * @param $created Bool: Whether this undeletion recreated the page |
93 | | - * @param $comment String: Undeletion summary |
94 | 93 | */ |
95 | | - public static function gadgetDefinitionUndelete( $title, $created, $comment ) { |
| 94 | + public static function gadgetDefinitionUpdateIfChanged( $title ) { |
96 | 95 | $id = self::getIDFromTitle( $title ); |
97 | 96 | if ( !$id ) { |
98 | | - return true; |
| 97 | + return; |
99 | 98 | } |
100 | 99 | |
101 | 100 | // Check whether this undeletion changed the latest revision of the page, by comparing |
— | — | @@ -107,7 +106,7 @@ |
108 | 107 | if ( wfTimestamp( TS_MW, $rev->getTimestamp() ) === |
109 | 108 | wfTimestamp( TS_MW, $gadgetTS ) ) { |
110 | 109 | // The latest rev didn't change. Someone must've undeleted an older revision |
111 | | - return true; |
| 110 | + return; |
112 | 111 | } |
113 | 112 | |
114 | 113 | // Update the database entry for this gadget |
— | — | @@ -116,14 +115,22 @@ |
117 | 116 | |
118 | 117 | // modifyGadget() returns a Status object with an error if there was a conflict, |
119 | 118 | // 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 ); |
120 | 130 | return true; |
121 | 131 | } |
122 | 132 | |
123 | 133 | 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 ); |
128 | 135 | return true; |
129 | 136 | } |
130 | 137 | |