Index: trunk/phase3/includes/Math.php |
— | — | @@ -145,6 +145,10 @@ |
146 | 146 | return $this->_error( 'math_image_error' ); |
147 | 147 | } |
148 | 148 | |
| 149 | + if( filesize( "$wgTmpDirectory/{$this->hash}.png" ) == 0 ) { |
| 150 | + return $this->_error( 'math_image_error' ); |
| 151 | + } |
| 152 | + |
149 | 153 | $hashpath = $this->_getHashPath(); |
150 | 154 | if( !file_exists( $hashpath ) ) { |
151 | 155 | if( !@wfMkdirParents( $hashpath, 0755 ) ) { |
— | — | @@ -175,7 +179,14 @@ |
176 | 180 | ), $fname |
177 | 181 | ); |
178 | 182 | } |
179 | | - |
| 183 | + |
| 184 | + // If we're replacing an older version of the image, make sure it's current. |
| 185 | + global $wgUseSquid; |
| 186 | + if ( $wgUseSquid ) { |
| 187 | + $urls = array( $this->_mathImageUrl() ); |
| 188 | + $u = new SquidUpdate( $urls ); |
| 189 | + $u->doUpdate(); |
| 190 | + } |
180 | 191 | } |
181 | 192 | |
182 | 193 | return $this->_doRender(); |
— | — | @@ -274,10 +285,7 @@ |
275 | 286 | } |
276 | 287 | |
277 | 288 | function _linkToMathImage() { |
278 | | - global $wgMathPath; |
279 | | - $url = "$wgMathPath/" . substr($this->hash, 0, 1) |
280 | | - .'/'. substr($this->hash, 1, 1) .'/'. substr($this->hash, 2, 1) |
281 | | - . "/{$this->hash}.png"; |
| 289 | + $url = $this->_mathImageUrl(); |
282 | 290 | |
283 | 291 | return Xml::element( 'img', |
284 | 292 | $this->_attribs( |
— | — | @@ -289,14 +297,24 @@ |
290 | 298 | 'src' => $url ) ) ); |
291 | 299 | } |
292 | 300 | |
| 301 | + function _mathImageUrl() { |
| 302 | + global $wgMathPath; |
| 303 | + $dir = $this->_getHashSubPath(); |
| 304 | + return "$wgMathPath/$dir/$this->hash"; |
| 305 | + } |
| 306 | + |
293 | 307 | function _getHashPath() { |
294 | 308 | global $wgMathDirectory; |
295 | | - $path = $wgMathDirectory .'/'. substr($this->hash, 0, 1) |
296 | | - .'/'. substr($this->hash, 1, 1) |
297 | | - .'/'. substr($this->hash, 2, 1); |
| 309 | + $path = $wgMathDirectory .'/' . $this->_getHashSubPath(); |
298 | 310 | wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" ); |
299 | 311 | return $path; |
300 | 312 | } |
| 313 | + |
| 314 | + function _getHashSubPath() { |
| 315 | + return substr($this->hash, 0, 1) |
| 316 | + .'/'. substr($this->hash, 1, 1) |
| 317 | + .'/'. substr($this->hash, 2, 1); |
| 318 | + } |
301 | 319 | |
302 | 320 | public static function renderMath( $tex, $params=array() ) { |
303 | 321 | global $wgUser; |