r113225 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113224‎ | r113225 | r113226 >
Date:11:45, 7 March 2012
Author:santhosh
Status:resolved (Comments)
Tags:i18nreview 
Comment:
Clear the associated metadata when a translatable page is deleted.
Move the associated metadata when a translatable page is moved.
Modified paths:
  • /trunk/extensions/Translate/tag/SpecialPageTranslationDeletePage.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslationMovePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/SpecialPageTranslationDeletePage.php
@@ -316,6 +316,7 @@
317317 $this->page->removeTags();
318318 }
319319
 320+ $this->clearMetadata();
320321 MessageGroups::clearCache();
321322 MessageIndexRebuildJob::newJob()->insert();
322323
@@ -323,6 +324,14 @@
324325 $wgOut->addWikiMsg( 'pt-deletepage-started' );
325326 }
326327
 328+ protected function clearMetadata() {
 329+ // remove the entries from metadata table.
 330+ $groupId = $this->page->getMessageGroupId();
 331+ TranslateMetadata::set( $groupId, 'prioritylangs', false );
 332+ TranslateMetadata::set( $groupId, 'priorityforce', false );
 333+ TranslateMetadata::set( $groupId, 'priorityreason', false );
 334+ }
 335+
327336 /**
328337 * Returns all section pages, including those which are currently not active.
329338 * @return TitleArray.
Index: trunk/extensions/Translate/tag/SpecialPageTranslationMovePage.php
@@ -396,6 +396,11 @@
397397 $newTpage->addMarkedTag( $this->newTitle->getLatestRevId( Title::GAID_FOR_UPDATE ) );
398398 }
399399
 400+ // remove the entries from metadata table.
 401+ $oldGroupId = $this->page->getMessageGroupId();
 402+ $newGroupId = $newTpage->getMessageGroupId();
 403+ $this->moveMetadata( $oldGroupId, $newGroupId );
 404+
400405 MessageGroups::clearCache();
401406 MessageIndexRebuildJob::newJob()->insert();
402407
@@ -403,6 +408,24 @@
404409 $wgOut->addWikiMsg( 'pt-movepage-started' );
405410 }
406411
 412+ protected function moveMetadata( $oldGroupId, $newGroupId ) {
 413+ $prioritylangs = TranslateMetadata::get( $oldGroupId, 'prioritylangs' );
 414+ $priorityforce = TranslateMetadata::get( $oldGroupId, 'priorityforce' );
 415+ $priorityreason = TranslateMetadata::get( $oldGroupId, 'priorityreason' );
 416+ TranslateMetadata::set( $oldGroupId, 'prioritylangs', false );
 417+ TranslateMetadata::set( $oldGroupId, 'priorityforce', false );
 418+ TranslateMetadata::set( $oldGroupId, 'priorityreason', false );
 419+ if ( $prioritylangs ) {
 420+ TranslateMetadata::set( $newGroupId, 'prioritylangs', $prioritylangs );
 421+ }
 422+ if ( $priorityforce ) {
 423+ TranslateMetadata::set( $newGroupId, 'priorityforce', $priorityforce );
 424+ }
 425+ if ( $priorityreason ) {
 426+ TranslateMetadata::set( $newGroupId, 'priorityreason', $priorityreason );
 427+ }
 428+ }
 429+
407430 protected function checkMoveBlockers() {
408431 $blockers = array();
409432

Follow-up revisions

RevisionCommit summaryAuthorDate
r114003Handle an edge case where $priorityreason is "0" and evaluates to false makin...santhosh07:24, 16 March 2012

Comments

#Comment by Nikerabbit (talk | contribs)   21:16, 8 March 2012

If somebody would happen to have "00" or similar as the reason, this would remove it. Not a big issue though.

#Comment by Santhosh.thottingal (talk | contribs)   16:45, 15 March 2012

"00" evaluates to true. So the edge case here is priority reason like "0" and moveMetadata not moving it to the metadata of new page.

Status & tagging log