r43965 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43964‎ | r43965 | r43966 >
Date:02:28, 26 November 2008
Author:brion
Status:resolved
Tags:
Comment:
Follow-up to r43964 (bug 16440)
* Purge newly rendered math images from squids, so any old bad versions get purged out
* Don't save entries that were 0-byte files
Modified paths:
  • /trunk/phase3/includes/Math.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Math.php
@@ -145,6 +145,10 @@
146146 return $this->_error( 'math_image_error' );
147147 }
148148
 149+ if( filesize( "$wgTmpDirectory/{$this->hash}.png" ) == 0 ) {
 150+ return $this->_error( 'math_image_error' );
 151+ }
 152+
149153 $hashpath = $this->_getHashPath();
150154 if( !file_exists( $hashpath ) ) {
151155 if( !@wfMkdirParents( $hashpath, 0755 ) ) {
@@ -175,7 +179,14 @@
176180 ), $fname
177181 );
178182 }
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+ }
180191 }
181192
182193 return $this->_doRender();
@@ -274,10 +285,7 @@
275286 }
276287
277288 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();
282290
283291 return Xml::element( 'img',
284292 $this->_attribs(
@@ -289,14 +297,24 @@
290298 'src' => $url ) ) );
291299 }
292300
 301+ function _mathImageUrl() {
 302+ global $wgMathPath;
 303+ $dir = $this->_getHashSubPath();
 304+ return "$wgMathPath/$dir/$this->hash";
 305+ }
 306+
293307 function _getHashPath() {
294308 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();
298310 wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" );
299311 return $path;
300312 }
 313+
 314+ function _getHashSubPath() {
 315+ return substr($this->hash, 0, 1)
 316+ .'/'. substr($this->hash, 1, 1)
 317+ .'/'. substr($this->hash, 2, 1);
 318+ }
301319
302320 public static function renderMath( $tex, $params=array() ) {
303321 global $wgUser;

Follow-up revisions

RevisionCommit summaryAuthorDate
r43966fix regression from r43965 -- forgot the .png extension from math URLs, which...brion02:37, 26 November 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r43964* (bug 16440) Broken 0-byte math renderings are now deleted and re-rendered ...brion02:13, 26 November 2008

Status & tagging log