Index: trunk/extensions/Translate/utils/MessageIndex.php |
— | — | @@ -40,11 +40,14 @@ |
41 | 41 | abstract public function retrieve(); |
42 | 42 | abstract protected function store( array $array ); |
43 | 43 | |
44 | | - public function rebuild() { |
| 44 | + public function rebuild( /*bool*/ $scratch = false ) { |
45 | 45 | $groups = MessageGroups::singleton()->getGroups(); |
46 | 46 | |
47 | | - $old = $this->retrieve(); |
48 | | - $new = array(); |
| 47 | + $new = $old = array(); |
| 48 | + if ( !$scratch ) { |
| 49 | + // To avoid inifinite recursion |
| 50 | + $old = $this->retrieve(); |
| 51 | + } |
49 | 52 | $postponed = array(); |
50 | 53 | |
51 | 54 | STDOUT( "Working with ", 'main' ); |
— | — | @@ -69,6 +72,7 @@ |
70 | 73 | |
71 | 74 | $this->store( $new ); |
72 | 75 | $this->clearMessageGroupStats( $old, $new ); |
| 76 | + return $new; |
73 | 77 | } |
74 | 78 | |
75 | 79 | /** |
— | — | @@ -165,7 +169,7 @@ |
166 | 170 | if ( file_exists( $file ) ) { |
167 | 171 | return $this->index = unserialize( file_get_contents( $file ) ); |
168 | 172 | } else { |
169 | | - return $this->index = array(); |
| 173 | + return $this->index = $this->rebuild( 'empty' ); |
170 | 174 | } |
171 | 175 | } |
172 | 176 | |
— | — | @@ -198,7 +202,7 @@ |
199 | 203 | if ( is_array( $data ) ) { |
200 | 204 | return $this->index = $data; |
201 | 205 | } else { |
202 | | - return $this->index = array(); |
| 206 | + return $this->index = $this->rebuild( 'empty' ); |
203 | 207 | } |
204 | 208 | } |
205 | 209 | |