http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90824

Revision: 90824
Author:   nikerabbit
Date:     2011-06-26 08:54:17 +0000 (Sun, 26 Jun 2011)
Log Message:
-----------
Hopefully fix marking page for translation for the first time

Modified Paths:
--------------
    trunk/extensions/Translate/tag/SpecialPageTranslation.php

Modified: trunk/extensions/Translate/tag/SpecialPageTranslation.php
===================================================================
--- trunk/extensions/Translate/tag/SpecialPageTranslation.php   2011-06-26 
06:19:05 UTC (rev 90823)
+++ trunk/extensions/Translate/tag/SpecialPageTranslation.php   2011-06-26 
08:54:17 UTC (rev 90824)
@@ -529,6 +529,7 @@
                $page->getTranslationPercentages( /*re-generate*/ true );
                ArrayMemoryCache::factory( 'groupstats' )->clearGroup( 
$page->getMessageGroupId() );
                MessageIndexRebuilder::execute();
+               MessageGroups::clearCache();
                return false;
        }
 
@@ -574,14 +575,8 @@
        }
 
        public function setupRenderJobs( TranslatablePage $page ) {
-               global $wgContLang;
                $titles = $page->getTranslationPages();
-
-               # If this page is marked for the first time, /en may not yet 
exists
-               # TODO: make sure there will be no two render jobs for the same 
subpage
-               $en = Title::newFromText( $page->getTitle()->getPrefixedText() 
. '/' . $wgContLang->getCode() );
-               $titles[] = $en;
-               
+               $this->addInitialRenderJob( $page, $titles );
                $jobs = array();
 
                foreach ( $titles as $t ) {
@@ -602,6 +597,27 @@
        }
 
        /**
+        * If this page is marked for the first time, /en may not yet exists.
+        * If this is the case, add a RenderJob for it, but don't execute it
+        * immediately, since the message group doesn't exist during this 
request.
+        */
+       protected function addInitialRenderJob( $page, $titles ) {
+               global $wgContLang;
+               $en = Title::newFromText( $page->getTitle()->getPrefixedText() 
. '/' . $wgContLang->getCode() );
+               $hasen = false;
+               foreach ( $titles as $t ) {
+                       if ( $t->equals( $en ) ) {
+                               $hasen = true;
+                               break;
+                       }
+               }
+
+               if ( !$hasen ) {
+                       $job = RenderJob::newJob( $en )->insert();
+               }
+       }
+
+       /**
         * Enhanced version of wfDebug that allows more detailed debugging.
         * You can pass anything as varags and it will be serialized. Article
         * and User objects have special handling to only output name and id.


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to