Merge "Further fix to profiling order for DBPerformance log"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 23 Aug 2013 18:09:58 +0000 (18:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 23 Aug 2013 18:09:58 +0000 (18:09 +0000)
includes/filerepo/file/LocalFile.php
resources/jquery.chosen/chosen.jquery.js
resources/mediawiki/mediawiki.htmlform.js
thumb.php

index 678a6ad..39ef62c 100644 (file)
@@ -1527,7 +1527,6 @@ class LocalFile extends File {
         * @return FileRepoStatus object.
         */
        function delete( $reason, $suppress = false ) {
-               global $wgUseSquid;
                if ( $this->getRepo()->getReadOnlyReason() !== false ) {
                        return $this->readOnlyFatalStatus();
                }
@@ -1545,19 +1544,28 @@ class LocalFile extends File {
                        DeferredUpdates::addUpdate( SiteStatsUpdate::factory( array( 'images' => -1 ) ) );
                }
 
-               $this->purgeEverything();
-               foreach ( $archiveNames as $archiveName ) {
-                       $this->purgeOldThumbnails( $archiveName );
-               }
+               // Hack: the lock()/unlock() pair is nested in a transaction so the locking is not
+               // tied to BEGIN/COMMIT. To avoid slow purges in the transaction, move them outside.
+               $file = $this;
+               $this->getRepo()->getMasterDB()->onTransactionIdle(
+                       function() use ( $file, $archiveNames ) {
+                               global $wgUseSquid;
 
-               if ( $wgUseSquid ) {
-                       // Purge the squid
-                       $purgeUrls = array();
-                       foreach ($archiveNames as $archiveName ) {
-                               $purgeUrls[] = $this->getArchiveUrl( $archiveName );
+                               $file->purgeEverything();
+                               foreach ( $archiveNames as $archiveName ) {
+                                       $file->purgeOldThumbnails( $archiveName );
+                               }
+
+                               if ( $wgUseSquid ) {
+                                       // Purge the squid
+                                       $purgeUrls = array();
+                                       foreach ( $archiveNames as $archiveName ) {
+                                               $purgeUrls[] = $file->getArchiveUrl( $archiveName );
+                                       }
+                                       SquidUpdate::purge( $purgeUrls );
+                               }
                        }
-                       SquidUpdate::purge( $purgeUrls );
-               }
+               );
 
                return $status;
        }
index a240ebd..745174f 100644 (file)
@@ -391,7 +391,7 @@ Copyright (c) 2011 by Harvest
       };
       this.container = $("<div />", container_props);
       if (this.is_multiple) {
-        this.container.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>');
+        this.container.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:auto;" /></li></ul><div class="chzn-drop"><ul class="chzn-results"></ul></div>');
       } else {
         this.container.html('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
       }
index 8e764e1..de06859 100644 (file)
                $fieldLabelText.text( $oldContainer.find( '.mw-label label' ).text() );
                $fieldLabel.append( $fieldLabelText );
                $container.prepend( $fieldLabel );
-               $oldContainer.parent().append( $container );
-               $oldContainer.remove();
+               $oldContainer.replaceWith( $container );
                return $container;
        }
 
index b9826a7..22a5b3d 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -94,7 +94,7 @@ function wfThumbHandle404() {
 function wfStreamThumb( array $params ) {
        global $wgVaryOnXFP;
 
-       wfProfileIn( __METHOD__ );
+       $section = new ProfileSection( __METHOD__ );
 
        $headers = array(); // HTTP headers to send
 
@@ -136,13 +136,11 @@ function wfStreamThumb( array $params ) {
                $bits = explode( '!', $fileName, 2 );
                if ( count( $bits ) != 2 ) {
                        wfThumbError( 404, wfMessage( 'badtitletext' )->text() );
-                       wfProfileOut( __METHOD__ );
                        return;
                }
                $title = Title::makeTitleSafe( NS_FILE, $bits[1] );
                if ( !$title ) {
                        wfThumbError( 404, wfMessage( 'badtitletext' )->text() );
-                       wfProfileOut( __METHOD__ );
                        return;
                }
                $img = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $fileName );
@@ -153,7 +151,6 @@ function wfStreamThumb( array $params ) {
        // Check the source file title
        if ( !$img ) {
                wfThumbError( 404, wfMessage( 'badtitletext' )->text() );
-               wfProfileOut( __METHOD__ );
                return;
        }
 
@@ -163,7 +160,6 @@ function wfStreamThumb( array $params ) {
                if ( !$img->getTitle() || !$img->getTitle()->userCan( 'read' ) ) {
                        wfThumbError( 403, 'Access denied. You do not have permission to access ' .
                                'the source file.' );
-                       wfProfileOut( __METHOD__ );
                        return;
                }
                $headers[] = 'Cache-Control: private';
@@ -173,11 +169,9 @@ function wfStreamThumb( array $params ) {
        // Check the source file storage path
        if ( !$img->exists() ) {
                wfThumbError( 404, "The source file '$fileName' does not exist." );
-               wfProfileOut( __METHOD__ );
                return;
        } elseif ( $img->getPath() === false ) {
                wfThumbError( 500, "The source file '$fileName' is not locally accessible." );
-               wfProfileOut( __METHOD__ );
                return;
        }
 
@@ -192,7 +186,6 @@ function wfStreamThumb( array $params ) {
                wfRestoreWarnings();
                if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) {
                        header( 'HTTP/1.1 304 Not Modified' );
-                       wfProfileOut( __METHOD__ );
                        return;
                }
        }
@@ -202,13 +195,11 @@ function wfStreamThumb( array $params ) {
                $thumbName = $img->thumbName( $params );
                if ( !strlen( $thumbName ) ) { // invalid params?
                        wfThumbError( 400, 'The specified thumbnail parameters are not valid.' );
-                       wfProfileOut( __METHOD__ );
                        return;
                }
                $thumbName2 = $img->thumbName( $params, File::THUMB_FULL_NAME ); // b/c; "long" style
        } catch ( MWException $e ) {
                wfThumbError( 500, $e->getHTML() );
-               wfProfileOut( __METHOD__ );
                return;
        }
 
@@ -233,13 +224,11 @@ function wfStreamThumb( array $params ) {
                        if ( count( $varyHeader ) ) {
                                $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
                        }
-                       wfProfileOut( __METHOD__ );
                        return;
                } else {
                        wfThumbError( 404, "The given path of the specified thumbnail is incorrect;
                                expected '" . $img->getThumbRel( $thumbName ) . "' but got '" .
                                rawurldecode( $params['rel404'] ) . "'." );
-                       wfProfileOut( __METHOD__ );
                        return;
                }
        }
@@ -255,7 +244,6 @@ function wfStreamThumb( array $params ) {
        $thumbPath = $img->getThumbPath( $thumbName );
        if ( $img->getRepo()->fileExists( $thumbPath ) ) {
                $img->getRepo()->streamFile( $thumbPath, $headers );
-               wfProfileOut( __METHOD__ );
                return;
        }
 
@@ -287,8 +275,6 @@ function wfStreamThumb( array $params ) {
                // Stream the file if there were no errors
                $thumb->streamFile( $headers );
        }
-
-       wfProfileOut( __METHOD__ );
 }
 
 /**