Index: trunk/extensions/Translate/utils/MessageIndex.php |
— | — | @@ -64,14 +64,22 @@ |
65 | 65 | abstract public function retrieve(); |
66 | 66 | abstract protected function store( array $array ); |
67 | 67 | |
68 | | - public function rebuild( /*bool*/ $scratch = false ) { |
| 68 | + public function rebuild() { |
| 69 | + static $recursion = 0; |
| 70 | + |
| 71 | + if ( $recursion > 0 ) { |
| 72 | + $msg = __METHOD__ . ': trying to recurse - building the index first time?'; |
| 73 | + STDERR( $msg ); |
| 74 | + wfDebug( "$msg\n" ); |
| 75 | + return array(); |
| 76 | + } |
| 77 | + $recursion++; |
| 78 | + |
| 79 | + |
69 | 80 | $groups = MessageGroups::singleton()->getGroups(); |
70 | 81 | |
71 | 82 | $new = $old = array(); |
72 | | - if ( !$scratch ) { |
73 | | - // To avoid inifinite recursion |
74 | | - $old = $this->retrieve(); |
75 | | - } |
| 83 | + $old = $this->retrieve(); |
76 | 84 | $postponed = array(); |
77 | 85 | |
78 | 86 | STDOUT( "Working with ", 'main' ); |
— | — | @@ -96,6 +104,7 @@ |
97 | 105 | |
98 | 106 | $this->store( $new ); |
99 | 107 | $this->clearMessageGroupStats( $old, $new ); |
| 108 | + $recursion--; |
100 | 109 | return $new; |
101 | 110 | } |
102 | 111 | |
— | — | @@ -196,7 +205,7 @@ |
197 | 206 | if ( file_exists( $file ) ) { |
198 | 207 | return $this->index = unserialize( file_get_contents( $file ) ); |
199 | 208 | } else { |
200 | | - return $this->index = $this->rebuild( 'empty' ); |
| 209 | + return $this->index = $this->rebuild(); |
201 | 210 | } |
202 | 211 | } |
203 | 212 | |
— | — | @@ -232,7 +241,7 @@ |
233 | 242 | if ( is_array( $data ) ) { |
234 | 243 | return $this->index = $data; |
235 | 244 | } else { |
236 | | - return $this->index = $this->rebuild( 'empty' ); |
| 245 | + return $this->index = $this->rebuild(); |
237 | 246 | } |
238 | 247 | } |
239 | 248 | |