Index: trunk/extensions/GPoC/GPoC.hooks.php |
— | — | @@ -36,6 +36,11 @@ |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
| 40 | + public static function TitleMoveComplete( &$title, &$newtitle, &$user, $oldid, $newid ) { |
| 41 | + Rating::moveArticle( $title, $newtitle ); |
| 42 | + return true; |
| 43 | + } |
| 44 | + |
40 | 45 | public static function ArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId) { |
41 | 46 | global $wgParser; |
42 | 47 | $title = $article->getTitle(); |
Index: trunk/extensions/GPoC/models/Rating.php |
— | — | @@ -183,4 +183,33 @@ |
184 | 184 | } |
185 | 185 | return $ratings; |
186 | 186 | } |
| 187 | + |
| 188 | + public static function moveArticle( $oldTitle, $newTitle ) { |
| 189 | + // Can be optimized to use two queries - so we touch DB_MASTER only if necessary |
| 190 | + // But is that a good thing? |
| 191 | + $dbw = wfGetDB( DB_MASTER ); |
| 192 | + $dbw->update( |
| 193 | + 'ratings', |
| 194 | + array( |
| 195 | + 'r_namespace' => $newTitle->getNamespace(), |
| 196 | + 'r_article' => $newTitle->getText() |
| 197 | + ), |
| 198 | + array( |
| 199 | + 'r_namespace' => $oldTitle->getNamespace(), |
| 200 | + 'r_article' => $oldTitle->getText() |
| 201 | + ), |
| 202 | + __METHOD__ |
| 203 | + ); |
| 204 | + $timestamp = wfTimestamp( TS_MW ); |
| 205 | + AssessmentChangeLog::makeEntry( |
| 206 | + "", |
| 207 | + $newTitle->getNamespace(), |
| 208 | + $newTitle->getText(), |
| 209 | + $timestamp, |
| 210 | + "articlemove", |
| 211 | + $oldTitle->getFullText(), |
| 212 | + $newTitle->getFullText() |
| 213 | + ); |
| 214 | + |
| 215 | + } |
187 | 216 | } |
Index: trunk/extensions/GPoC/GPoC.php |
— | — | @@ -32,4 +32,6 @@ |
33 | 33 | $wgHooks['ParserFirstCallInit'][] = 'TableDisplay::ParserFunctionInit'; |
34 | 34 | $wgHooks['LanguageGetMagic'][] = 'TableDisplay::LanguageGetMagic'; |
35 | 35 | |
| 36 | +$wgHooks['TitleMoveComplete'][] = 'GPoCHooks::TitleMoveComplete'; |
| 37 | + |
36 | 38 | // Configuration |