r89495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89494‎ | r89495 | r89496 >
Date:11:17, 5 June 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Various fixes to transla* page deletion
Modified paths:
  • /trunk/extensions/Translate/PageTranslation.i18n.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/tag/DeleteJob.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslationDeletePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/SpecialPageTranslationDeletePage.php
@@ -260,16 +260,16 @@
261261 protected function performAction() {
262262 $jobs = array();
263263 $target = $this->title;
 264+ $base = $this->title->getPrefixedText();
264265
265266 $translationPages = $this->getTranslationPages();
266267 foreach ( $translationPages as $old ) {
267 - $jobs[$old->getPrefixedText()] = DeleteJob::newJob( $old, !$this->singleLanguage(), $this->user );
 268+ $jobs[$old->getPrefixedText()] = DeleteJob::newJob( $old, $base, !$this->singleLanguage(), $this->user );
268269 }
269270
270271 $sectionPages = $this->getSectionPages();
271272 foreach ( $sectionPages as $old ) {
272 - $to = $this->newPageTitle( $base, $old, $target );
273 - $jobs[$old->getPrefixedText()] = DeleteJob::newJob( $old, !$this->singleLanguage(), $this->user );
 273+ $jobs[$old->getPrefixedText()] = DeleteJob::newJob( $old, $base, !$this->singleLanguage(), $this->user );
274274 }
275275
276276 if ( !$this->doSubpages ) {
@@ -279,15 +279,14 @@
280280 continue;
281281 }
282282
283 - $to = $this->newPageTitle( $base, $old, $target );
284 - $jobs[$old->getPrefixedText()] = DeleteJob::newJob( $old, !$this->singleLanguage(), $this->user );
 283+ $jobs[$old->getPrefixedText()] = DeleteJob::newJob( $old, $base, !$this->singleLanguage(), $this->user );
285284 }
286285 }
287286
288287 Job::batchInsert( $jobs );
289288
290 - global $wgMemc;
291 - $wgMemc->set( wfMemcKey( 'pt-base', $base ), array_keys( $jobs ), 60 * 60 * 6 );
 289+ $cache = wfGetCache( CACHE_DB );
 290+ $cache->set( wfMemcKey( 'pt-base', $target->getPrefixedText() ), array_keys( $jobs ), 60 * 60 * 6 );
292291
293292
294293 if ( !$this->singleLanguage() ) {
@@ -296,7 +295,7 @@
297296
298297 MessageGroups::clearCache();
299298 // TODO: defer or make faster
300 - MessageIndexRebuilder::execute();
 299+ //MessageIndexRebuilder::execute();
301300
302301 global $wgOut;
303302 $wgOut->addWikiMsg( 'pt-deletepage-started' );
Index: trunk/extensions/Translate/tag/DeleteJob.php
@@ -15,16 +15,16 @@
1616 * @todo Get rid of direct reference to $wgMemc.
1717 */
1818 class DeleteJob extends Job {
19 - public static function newJob( Title $target, $full, /*User*/ $performer ) {
 19+ public static function newJob( Title $target, $base, $full, /*User*/ $performer ) {
2020 global $wgTranslateFuzzyBotName;
2121
2222 $job = new self( $target );
2323 $job->setUser( $wgTranslateFuzzyBotName );
2424 $job->setFull( $full );
 25+ $job->setBase( $base );
2526 $msg = $job->getFull() ? 'pt-deletepage-full-logreason' : 'pt-deletepage-lang-logreason';
26 - $job->setSummary( wfMsgForContent( 'pt-deletepage-logreason', $target->getPrefixedText() ) );
 27+ $job->setSummary( wfMsgForContent( $msg, $target->getPrefixedText() ) );
2728 $job->setPerformer( $performer );
28 - $job->lock();
2929 return $job;
3030 }
3131
@@ -40,7 +40,7 @@
4141 // Other stuff
4242 $user = $this->getUser();
4343 $summary = $this->getSummary();
44 - $target = $this->getTarget();
 44+ $base = $this->getBase();
4545
4646 PageTranslationHooks::$allowTargetEdit = true;
4747 $oldUser = $wgUser;
@@ -53,7 +53,7 @@
5454 $logger = new LogPage( 'pagetranslation' );
5555 $params = array(
5656 'user' => $this->getPerformer(),
57 - 'target' => $target->getPrefixedText(),
 57+ 'target' => $title->getPrefixedText(),
5858 'error' => base64_encode( serialize( $ok ) ), // This is getting ridiculous
5959 );
6060 $doer = User::newFromName( $this->getPerformer() );
@@ -63,24 +63,23 @@
6464
6565 PageTranslationHooks::$allowTargetEdit = false;
6666
67 - global $wgMemc;
68 - $pages = (array) $wgMemc->get( wfMemcKey( 'pt-base', $title->getPrefixedText() ) );
69 - $last = true;
70 -
71 - foreach ( $pages as $page ) {
72 - if ( $wgMemc->get( wfMemcKey( 'pt-lock', $page ) ) === true ) {
73 - $last = false;
74 - break;
75 - }
76 - }
77 -
78 - if ( $last ) {
79 - $wgMemc->delete( wfMemcKey( 'pt-base', $title->getPrefixedText() ) );
 67+ $cache = wfGetCache( CACHE_DB );
 68+ $pages = (array) $cache->get( wfMemcKey( 'pt-base', $base ) );
 69+ $lastitem = array_pop( $pages );
 70+ if ( $title->getPrefixedText() === $lastitem ) {
 71+ $cache->delete( wfMemcKey( 'pt-base', $base ) );
8072 $logger = new LogPage( 'pagetranslation' );
8173 $params = array( 'user' => $this->getPerformer() );
8274 $doer = User::newFromName( $this->getPerformer() );
8375 $msg = $this->getFull() ? 'deletefok' : 'deletelok';
84 - $logger->addEntry( $msg, $title, null, array( serialize( $params ) ), $doer );
 76+ $logger->addEntry( $msg, Title::newFromText( $base ), null, array( serialize( $params ) ), $doer );
 77+
 78+ $tpage = TranslatablePage::newFromTitle( $title );
 79+ $tpage->getTranslationPercentages( true );
 80+ foreach ( $tpage->getTranslationPages() as $page ) {
 81+ $page->invalidateCache();
 82+ }
 83+ $title->invalidateCache();
8584 }
8685
8786 $wgUser = $oldUser;
@@ -124,6 +123,14 @@
125124 }
126125 }
127126
 127+ public function setBase( $base ) {
 128+ $this->params['base'] = $base;
 129+ }
 130+
 131+ public function getBase() {
 132+ return $this->params['base'];
 133+ }
 134+
128135 /**
129136 * Get a user object for doing edits.
130137 */
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -556,9 +556,9 @@
557557 return wfMsgExt( 'pt-log-delete-full-nok', $opts, $title->getPrefixedText(), $user, $_['target'] );
558558 } elseif ( $action === 'deletelnok' ) {
559559 return wfMsgExt( 'pt-log-delete-lang-nok', $opts, $title->getPrefixedText(), $user, $_['target'] );
 560+ } elseif ( $action === 'deletefok' ) {
 561+ return wfMsgExt( 'pt-log-delete-full-ok', $opts, $title->getPrefixedText(), $user );
560562 } elseif ( $action === 'deletelok' ) {
561 - return wfMsgExt( 'pt-log-delete-full-ok', $opts, $title->getPrefixedText(), $user );
562 - } elseif ( $action === 'deletefok' ) {
563563 return wfMsgExt( 'pt-log-delete-lang-ok', $opts, $title->getPrefixedText(), $user );
564564 }
565565 }
Index: trunk/extensions/Translate/Translate.php
@@ -553,10 +553,16 @@
554554 $wgLogActionsHandlers['pagetranslation/unmark'] = 'PageTranslationHooks::formatLogEntry';
555555 $wgLogActionsHandlers['pagetranslation/moveok'] = 'PageTranslationHooks::formatLogEntry';
556556 $wgLogActionsHandlers['pagetranslation/movenok'] = 'PageTranslationHooks::formatLogEntry';
 557+ $wgLogActionsHandlers['pagetranslation/deletelok'] = 'PageTranslationHooks::formatLogEntry';
 558+ $wgLogActionsHandlers['pagetranslation/deletefok'] = 'PageTranslationHooks::formatLogEntry';
 559+ $wgLogActionsHandlers['pagetranslation/deletelnok'] = 'PageTranslationHooks::formatLogEntry';
 560+ $wgLogActionsHandlers['pagetranslation/deletefnok'] = 'PageTranslationHooks::formatLogEntry';
557561
 562+
558563 global $wgJobClasses;
559564 $wgJobClasses['RenderJob'] = 'RenderJob';
560565 $wgJobClasses['MoveJob'] = 'MoveJob';
 566+ $wgJobClasses['DeleteJob'] = 'DeleteJob';
561567
562568 // Namespaces
563569 global $wgPageTranslationNamespace, $wgExtraNamespaces;
Index: trunk/extensions/Translate/PageTranslation.i18n.php
@@ -105,7 +105,7 @@
106106 'pt-log-movenok' => '{{GENDER:$2|encountered}} a problem while moving [[:$1]] to [[:$3]]',
107107 'pt-log-delete-full-ok' => '{{GENDER:$2|completed}} deletion of translatable page $1',
108108 'pt-log-delete-full-nok' => '{{GENDER:$2|encountered}} a problem while deleting translatable page [[:$1]]',
109 - 'pt-log-delete-lang-ok' => '{{GENDER:$2|completed}} deletion of translation page $e',
 109+ 'pt-log-delete-lang-ok' => '{{GENDER:$2|completed}} deletion of translation page $1',
110110 'pt-log-delete-lang-nok' => '{{GENDER:$2|encountered}} a problem while deleting translation page [[:$1]]',
111111
112112

Status & tagging log