Merge "parse argument for message 'ago' in MWTimestamp::getHumanTimestamp"
authorNikerabbit <niklas.laxstrom@gmail.com>
Fri, 7 Dec 2012 21:55:33 +0000 (21:55 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 7 Dec 2012 21:55:33 +0000 (21:55 +0000)
15 files changed:
includes/ImagePage.php
includes/Preferences.php
includes/UserMailer.php
includes/job/JobQueueDB.php
includes/job/jobs/DoubleRedirectJob.php
includes/job/jobs/NullJob.php
includes/upload/UploadFromStash.php
includes/upload/UploadFromUrl.php
languages/LanguageConverter.php
maintenance/fixDoubleRedirects.php
maintenance/mwdocgen.php
tests/phpunit/includes/DiffHistoryBlobTest.php
tests/phpunit/includes/parser/MediaWikiParserTest.php
tests/phpunit/includes/upload/UploadFromUrlTest.php
tests/phpunit/maintenance/MaintenanceTest.php

index 316e1c9..ecf4f89 100644 (file)
@@ -340,13 +340,13 @@ class ImagePage extends Article {
                                if ( $width > $maxWidth || $height > $maxHeight ) {
                                        # Calculate the thumbnail size.
                                        # First case, the limiting factor is the width, not the height.
-                                       if ( $width / $height >= $maxWidth / $maxHeight ) {
-                                               $height = round( $height * $maxWidth / $width );
+                                       if ( $width / $height >= $maxWidth / $maxHeight ) { // FIXME: Possible divison by 0. bug 36911
+                                               $height = round( $height * $maxWidth / $width ); // FIXME: Possible divison by 0. bug 36911
                                                $width = $maxWidth;
                                                # Note that $height <= $maxHeight now.
                                        } else {
-                                               $newwidth = floor( $width * $maxHeight / $height );
-                                               $height = round( $height * $newwidth / $width );
+                                               $newwidth = floor( $width * $maxHeight / $height ); // FIXME: Possible divison by 0. bug 36911
+                                               $height = round( $height * $newwidth / $width ); // FIXME: Possible divison by 0. bug 36911
                                                $width = $newwidth;
                                                # Note that $height <= $maxHeight now, but might not be identical
                                                # because of rounding.
index a3c684b..a79f98f 100644 (file)
@@ -252,7 +252,7 @@ class Preferences {
                if ( $wgAuth->allowPasswordChange() ) {
                        $link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ),
                                $context->msg( 'prefs-resetpass' )->escaped(), array(),
-                               array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) );
+                               array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) );
 
                        $defaultPreferences['password'] = array(
                                'type' => 'info',
@@ -367,7 +367,7 @@ class Preferences {
                                SpecialPage::getTitleFor( 'ChangeEmail' ),
                                $context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(),
                                array(),
-                               array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) );
+                               array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) );
 
                        $emailAddress = $user->getEmail() ? htmlspecialchars( $user->getEmail() ) : '';
                        if ( $wgAuth->allowPropChange( 'emailaddress' ) ) {
index daf7435..8d1ed68 100644 (file)
@@ -498,7 +498,7 @@ class EmailNotification {
                                'pageStatus' => $pageStatus
                        );
                        $job = new EnotifNotifyJob( $title, $params );
-                       $job->insert();
+                       JobQueueGroup::singleton()->push( $job );
                } else {
                        $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $pageStatus );
                }
index 2f483ed..e23ff0d 100644 (file)
@@ -377,7 +377,8 @@ class JobQueueDB extends JobQueue {
                $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction
 
                // Delete a row with a single DELETE without holding row locks over RTTs...
-               $dbw->delete( 'job', array( 'job_cmd' => $this->type, 'job_id' => $job->getId() ) );
+               $dbw->delete( 'job',
+                       array( 'job_cmd' => $this->type, 'job_id' => $job->getId() ), __METHOD__ );
 
                return true;
        }
index ddd4fcc..fb73bf1 100644 (file)
@@ -66,11 +66,11 @@ class DoubleRedirectJob extends Job {
                                'redirTitle' => $redirTitle->getPrefixedDBkey() ) );
                        # Avoid excessive memory usage
                        if ( count( $jobs ) > 10000 ) {
-                               Job::batchInsert( $jobs );
+                               JobQueueGroup::singleton()->push( $jobs );
                                $jobs = array();
                        }
                }
-               Job::batchInsert( $jobs );
+               JobQueueGroup::singleton()->push( $jobs );
        }
 
        function __construct( $title, $params = false, $id = 0 ) {
index 99a8429..4996984 100644 (file)
@@ -52,7 +52,7 @@ class NullJob extends Job {
                        $params = $this->params;
                        $params['lives']--;
                        $job = new self( $this->title, $params );
-                       $job->insert();
+                       JobQueueGroup::singleton()->push( $job );
                }
                return true;
        }
index 55209d4..c857f25 100644 (file)
@@ -141,12 +141,13 @@ class UploadFromStash extends UploadBase {
        /**
         * Stash the file.
         *
+        * @param $user User
         * @return UploadStashFile
         */
-       public function stashFile() {
+       public function stashFile( User $user = null ) {
                // replace mLocalFile with an instance of UploadStashFile, which adds some methods
                // that are useful for stashed files.
-               $this->mLocalFile = parent::stashFile();
+               $this->mLocalFile = parent::stashFile( $user );
                return $this->mLocalFile;
        }
 
index 7f430c5..70b6903 100644 (file)
@@ -332,7 +332,7 @@ class UploadFromUrl extends UploadBase {
                        'sessionKey' => $sessionKey,
                ) );
                $job->initializeSessionData();
-               $job->insert();
+               JobQueueGroup::singleton()->push( $job );
                return $sessionKey;
        }
 
index 79783cc..fed8835 100644 (file)
@@ -618,6 +618,8 @@ class LanguageConverter {
                if ( $wgDisableLangConversion ) {
                        return $text;
                }
+               // Reset converter state for a new converter run.
+               $this->mConvRuleTitle = false;
                return $this->recursiveConvertTopLevel( $text, $variant );
        }
 
index d808500..19b9777 100644 (file)
@@ -129,7 +129,7 @@ class FixDoubleRedirects extends Maintenance {
 
        protected function queueJobs( $jobs, $dryrun = false ) {
                $this->output( "Queuing batch of " . count( $jobs ) . " double redirects.\n" );
-               Job::batchInsert( $dryrun ? array() : $jobs );
+               JobQueueGroup::singleton()->push( $dryrun ? array() : $jobs );
        }
 }
 
index e36674e..6e01291 100644 (file)
@@ -114,8 +114,7 @@ function readaline( $prompt = '' ) {
  * @param $doxyGenerateMan Boolean
  * @return string
  */
-function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $input, $exclude, $excludePatterns, $doxyGenerateMan ) {
-       global $doxygenInputFilter;
+function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $input, $exclude, $excludePatterns, $doxyGenerateMan, $doxygenInputFilter ) {
 
        $template = file_get_contents( $doxygenTemplate );
        // Replace template placeholders by correct values.
@@ -242,7 +241,7 @@ $version = 'master';
 $excludedPaths = $mwPath . join( " $mwPath", $mwExcludePaths );
 print "EXCLUDE: $excludedPaths\n\n";
 
-$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $input, $excludedPaths, $excludePatterns, $doxyGenerateMan );
+$generatedConf = generateConfigFile( $doxygenTemplate, $doxyOutput, $mwPath, $version, $input, $excludedPaths, $excludePatterns, $doxyGenerateMan, $doxygenInputFilter );
 $command = $doxygenBin . ' ' . $generatedConf;
 
 echo <<<TEXT
index d46e683..361b412 100644 (file)
@@ -14,6 +14,7 @@ class DiffHistoryBlobTest extends MediaWikiTestCase {
                        $this->markTestSkipped( 'Neither the hash nor mhash extension is available' );
                        return;
                }
+               parent::setUp();
        }
 
        /**
index 6a6fded..b15365c 100644 (file)
@@ -22,15 +22,13 @@ class MediaWikiParserTest {
                         * and then was ucfirst( basename( $filename, '.txt' )
                         * but that didn't work with names like foo.tests.txt
                         */
-                       $className = str_replace( '.', '_',  ucfirst( basename( $filename, '.txt' ) ) );
-                       
+                       $className = str_replace( '.', '_',  ucfirst( $testsName ) );
+
                        eval( "/** @group Database\n@group Parser\n*/ class $className extends NewParserTest { protected \$file = '" . strtr( $filename, array( "'" => "\\'", '\\' => '\\\\' ) ) . "'; } " );
 
                        $parserTester = new $className( $testsName );
                        $suite->addTestSuite( new ReflectionClass ( $parserTester ) );
                }
-               
-
                return $suite;
        }
 }
index 59663ba..307810d 100644 (file)
@@ -36,9 +36,9 @@ class UploadFromUrlTest extends ApiTestCase {
         * Ensure that the job queue is empty before continuing
         */
        public function testClearQueue() {
-               $job = Job::pop();
+               $job = JobQueueGroup::singleton()->pop();
                while ( $job ) {
-                       $job = Job::pop();
+                       $job = JobQueueGroup::singleton()->pop();
                }
                $this->assertFalse( $job );
        }
@@ -141,7 +141,7 @@ class UploadFromUrlTest extends ApiTestCase {
 
                $this->assertEquals( $data[0]['upload']['result'], 'Queued', 'Queued upload' );
 
-               $job = Job::pop();
+               $job = JobQueueGroup::singleton()->pop();
                $this->assertThat( $job, $this->isInstanceOf( 'UploadFromUrlJob' ), 'Queued upload inserted' );
        }
 
@@ -202,7 +202,7 @@ class UploadFromUrlTest extends ApiTestCase {
        public function testSyncDownload( $data ) {
                $token = $this->user->getEditToken();
 
-               $job = Job::pop();
+               $job = JobQueueGroup::singleton()->pop();
                $this->assertFalse( $job, 'Starting with an empty jobqueue' );
 
                $this->user->addGroup( 'users' );
@@ -214,7 +214,7 @@ class UploadFromUrlTest extends ApiTestCase {
                        'token' => $token,
                ), $data );
 
-               $job = Job::pop();
+               $job = JobQueueGroup::singleton()->pop();
                $this->assertFalse( $job );
 
                $this->assertEquals( 'Success', $data[0]['upload']['result'] );
@@ -244,7 +244,7 @@ class UploadFromUrlTest extends ApiTestCase {
                        'ignorewarnings' => 1,
                ) );
 
-               $job = Job::pop();
+               $job = JobQueueGroup::singleton()->pop();
                $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) );
                $job->run();
 
@@ -272,7 +272,7 @@ class UploadFromUrlTest extends ApiTestCase {
                }
                $this->assertTrue( $exception );
 
-               $job = Job::pop();
+               $job = JobQueueGroup::singleton()->pop();
                $this->assertFalse( $job );
 
                return;
@@ -314,7 +314,7 @@ class UploadFromUrlTest extends ApiTestCase {
                $this->assertTrue( isset( $data[0]['upload']['statuskey'] ) );
                $statusKey = $data[0]['upload']['statuskey'];
 
-               $job = Job::pop();
+               $job = JobQueueGroup::singleton()->pop();
                $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) );
 
                $status = $job->run();
index 4a6f08f..a0ed745 100644 (file)
@@ -88,15 +88,16 @@ class MaintenanceFixup extends Maintenance {
         * Safety net around register_shutdown_function of Maintenance.php
         */
        public function __destruct() {
-               if ( ( ! $this->shutdownSimulated ) && ( ! $this->testCase->hasFailed() ) ) {
+               if ( ! $this->shutdownSimulated ) {
                        // Someone generated a MaintenanceFixup instance without calling
                        // simulateShutdown. We'd have to raise a PHPUnit exception to correctly
                        // flag this illegal usage. However, we are already in a destruktor, which
                        // would trigger undefined behaviour. Hence, we can only report to the
                        // error output :( Hopefully people read the PHPUnit output.
-                       fwrite( STDERR, "ERROR! Instance of " . __CLASS__ . " destructed without "
-                               . "calling simulateShutdown method. Call simulateShutdown on the "
-                               . "instance before it gets destructed." );
+                       $name = $this->testCase->getName();
+                       fwrite( STDERR, "ERROR! Instance of " . __CLASS__ . " for test $name "
+                               . "destructed without calling simulateShutdown method. Call "
+                               . "simulateShutdown on the instance before it gets destructed." );
                }
 
                // The following guard is required, as PHP does not offer default destructors :(
@@ -148,6 +149,14 @@ class MaintenanceTest extends MediaWikiTestCase {
                $this->m = new MaintenanceFixup( $this );
        }
 
+       protected function tearDown() {
+               if ( $this->m ) {
+                       $this->m->simulateShutdown();
+                       $this->m = null;
+               }
+               parent::tearDown();
+       }
+
 
        /**
         * asserts the output before and after simulating shutdown
@@ -167,6 +176,7 @@ class MaintenanceTest extends MediaWikiTestCase {
                                "Output before shutdown simulation" );
 
                $this->m->simulateShutdown();
+               $this->m = null;
 
                $postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
                $this->expectOutputString( $postShutdownOutput );
@@ -809,4 +819,4 @@ class MaintenanceTest extends MediaWikiTestCase {
        }
 
 
-}
\ No newline at end of file
+}