Merge "Restore the number of rows shown on Special:Watchlist"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 29 Jul 2014 18:28:17 +0000 (18:28 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 29 Jul 2014 18:28:17 +0000 (18:28 +0000)
includes/EditPage.php
includes/media/SVG.php
maintenance/runJobs.php

index 50225cc..0a61a7e 100644 (file)
@@ -2524,7 +2524,9 @@ class EditPage {
 
                $wgOut->addHTML( $this->editFormTextBeforeContent );
 
-               if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption( 'showtoolbar' ) ) {
+               if ( $this->contentModel === CONTENT_MODEL_WIKITEXT &&
+                       $showToolbar && $wgUser->getOption( 'showtoolbar' ) )
+               {
                        $wgOut->addHTML( EditPage::getEditToolbar() );
                }
 
index e890b29..9245d42 100644 (file)
@@ -185,7 +185,40 @@ class SvgHandler extends ImageHandler {
                }
 
                $srcPath = $image->getLocalRefPath();
-               $status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight, $lang );
+               if ( $srcPath === false ) { // Failed to get local copy
+                       wfDebugLog( 'thumbnail',
+                               sprintf( 'Thumbnail failed on %s: could not get local copy of "%s"',
+                                       wfHostname(), $image->getName() ) );
+
+                       return new MediaTransformError( 'thumbnail_error',
+                               $params['width'], $params['height'],
+                               wfMessage( 'filemissing' )->text()
+                       );
+               }
+
+               // Make a temp dir with a symlink to the local copy in it.
+               // This plays well with rsvg-convert policy for external entities.
+               // https://git.gnome.org/browse/librsvg/commit/?id=f01aded72c38f0e18bc7ff67dee800e380251c8e
+               $tmpDir = wfTempDir() . '/svg_' . wfRandomString( 24 );
+               $lnPath = "$tmpDir/" . basename( $srcPath );
+               $ok = mkdir( $tmpDir, 0771 ) && symlink( $srcPath, $lnPath );
+               $cleaner = new ScopedCallback( function() use ( $tmpDir, $lnPath ) {
+                       wfSuppressWarnings();
+                       unlink( $lnPath );
+                       rmdir( $tmpDir );
+                       wfRestoreWarnings();
+               } );
+               if ( !$ok ) {
+                       wfDebugLog( 'thumbnail',
+                               sprintf( 'Thumbnail failed on %s: could not link %s to %s',
+                                       wfHostname(), $lnPath, $srcPath ) );
+                       return new MediaTransformError( 'thumbnail_error',
+                               $params['width'], $params['height'],
+                               wfMessage( 'thumbnail-temp-create' )->text()
+                       );
+               }
+
+               $status = $this->rasterize( $lnPath, $dstPath, $physicalWidth, $physicalHeight, $lang );
                if ( $status === true ) {
                        return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
                } else {
index c757802..40605ce 100644 (file)
@@ -37,7 +37,7 @@ class RunJobs extends Maintenance {
                $this->addOption( 'type', 'Type of job to run', false, true );
                $this->addOption( 'procs', 'Number of processes to use', false, true );
                $this->addOption( 'nothrottle', 'Ignore job throttling configuration', false, false );
-               $this->addOption( 'result', 'Set to JSON to print only a JSON response', false, false );
+               $this->addOption( 'result', 'Set to JSON to print only a JSON response', false, true );
        }
 
        public function memoryLimit() {