https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112001
Revision: 112001
Author: nikerabbit
Date: 2012-02-21 10:55:50 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
rebuild() was not dealing with recursion properly.
This lead to infinite loop, when there was no message index yet and translate
workflow states:
* rebuild loads groups
* workflow state group adds missing messages when it loads message keys
* onSave hook gets run when those messages are credited
* the hooks wants to know which message the page corresponds to
* so it loads message index
* which is messing, so rebuild() gets called again...
Modified Paths:
--------------
trunk/extensions/Translate/utils/MessageIndex.php
Modified: trunk/extensions/Translate/utils/MessageIndex.php
===================================================================
--- trunk/extensions/Translate/utils/MessageIndex.php 2012-02-21 10:36:27 UTC
(rev 112000)
+++ trunk/extensions/Translate/utils/MessageIndex.php 2012-02-21 10:55:50 UTC
(rev 112001)
@@ -64,14 +64,22 @@
abstract public function retrieve();
abstract protected function store( array $array );
- public function rebuild( /*bool*/ $scratch = false ) {
+ public function rebuild() {
+ static $recursion = 0;
+
+ if ( $recursion > 0 ) {
+ $msg = __METHOD__ . ': trying to recurse - building the
index first time?';
+ STDERR( $msg );
+ wfDebug( "$msg\n" );
+ return array();
+ }
+ $recursion++;
+
+
$groups = MessageGroups::singleton()->getGroups();
$new = $old = array();
- if ( !$scratch ) {
- // To avoid inifinite recursion
- $old = $this->retrieve();
- }
+ $old = $this->retrieve();
$postponed = array();
STDOUT( "Working with ", 'main' );
@@ -96,6 +104,7 @@
$this->store( $new );
$this->clearMessageGroupStats( $old, $new );
+ $recursion--;
return $new;
}
@@ -196,7 +205,7 @@
if ( file_exists( $file ) ) {
return $this->index = unserialize( file_get_contents(
$file ) );
} else {
- return $this->index = $this->rebuild( 'empty' );
+ return $this->index = $this->rebuild();
}
}
@@ -232,7 +241,7 @@
if ( is_array( $data ) ) {
return $this->index = $data;
} else {
- return $this->index = $this->rebuild( 'empty' );
+ return $this->index = $this->rebuild();
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs