r91725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91724‎ | r91725 | r91726 >
Date:14:13, 8 July 2011
Author:yuvipanda
Status:deferred
Tags:
Comment:
Handles article moves
Modified paths:
  • /trunk/extensions/GPoC/GPoC.hooks.php (modified) (history)
  • /trunk/extensions/GPoC/GPoC.php (modified) (history)
  • /trunk/extensions/GPoC/models/Rating.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GPoC/GPoC.hooks.php
@@ -36,6 +36,11 @@
3737 }
3838 }
3939
 40+ public static function TitleMoveComplete( &$title, &$newtitle, &$user, $oldid, $newid ) {
 41+ Rating::moveArticle( $title, $newtitle );
 42+ return true;
 43+ }
 44+
4045 public static function ArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId) {
4146 global $wgParser;
4247 $title = $article->getTitle();
Index: trunk/extensions/GPoC/models/Rating.php
@@ -183,4 +183,33 @@
184184 }
185185 return $ratings;
186186 }
 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+ }
187216 }
Index: trunk/extensions/GPoC/GPoC.php
@@ -32,4 +32,6 @@
3333 $wgHooks['ParserFirstCallInit'][] = 'TableDisplay::ParserFunctionInit';
3434 $wgHooks['LanguageGetMagic'][] = 'TableDisplay::LanguageGetMagic';
3535
 36+$wgHooks['TitleMoveComplete'][] = 'GPoCHooks::TitleMoveComplete';
 37+
3638 // Configuration

Status & tagging log