From: Nikerabbit Date: Fri, 7 Dec 2012 21:55:33 +0000 (+0000) Subject: Merge "parse argument for message 'ago' in MWTimestamp::getHumanTimestamp" X-Git-Tag: 1.31.0-rc.0~21389 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=881ef16f71c2429f2f645438c26fddbf9788c77c;hp=91e9fb60b7ae94f34697da104943c80e7a3a7e41;p=lhc%2Fweb%2Fwiklou.git Merge "parse argument for message 'ago' in MWTimestamp::getHumanTimestamp" --- diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 316e1c95b1..ecf4f894e1 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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. diff --git a/includes/Preferences.php b/includes/Preferences.php index a3c684b560..a79f98f285 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -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' ) ) { diff --git a/includes/UserMailer.php b/includes/UserMailer.php index daf74357a3..8d1ed6812f 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -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 ); } diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index 2f483ed4ed..e23ff0d905 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -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; } diff --git a/includes/job/jobs/DoubleRedirectJob.php b/includes/job/jobs/DoubleRedirectJob.php index ddd4fcca15..fb73bf1ee2 100644 --- a/includes/job/jobs/DoubleRedirectJob.php +++ b/includes/job/jobs/DoubleRedirectJob.php @@ -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 ) { diff --git a/includes/job/jobs/NullJob.php b/includes/job/jobs/NullJob.php index 99a8429f7c..4996984a8a 100644 --- a/includes/job/jobs/NullJob.php +++ b/includes/job/jobs/NullJob.php @@ -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; } diff --git a/includes/upload/UploadFromStash.php b/includes/upload/UploadFromStash.php index 55209d4840..c857f25466 100644 --- a/includes/upload/UploadFromStash.php +++ b/includes/upload/UploadFromStash.php @@ -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; } diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php index 7f430c50ad..70b6903458 100644 --- a/includes/upload/UploadFromUrl.php +++ b/includes/upload/UploadFromUrl.php @@ -332,7 +332,7 @@ class UploadFromUrl extends UploadBase { 'sessionKey' => $sessionKey, ) ); $job->initializeSessionData(); - $job->insert(); + JobQueueGroup::singleton()->push( $job ); return $sessionKey; } diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 79783cc14f..fed8835f7b 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -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 ); } diff --git a/maintenance/fixDoubleRedirects.php b/maintenance/fixDoubleRedirects.php index d808500d3d..19b977773e 100644 --- a/maintenance/fixDoubleRedirects.php +++ b/maintenance/fixDoubleRedirects.php @@ -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 ); } } diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php index e36674e400..6e01291eb7 100644 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -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 <<markTestSkipped( 'Neither the hash nor mhash extension is available' ); return; } + parent::setUp(); } /** diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php index 6a6fded17a..b15365c0c0 100644 --- a/tests/phpunit/includes/parser/MediaWikiParserTest.php +++ b/tests/phpunit/includes/parser/MediaWikiParserTest.php @@ -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; } } diff --git a/tests/phpunit/includes/upload/UploadFromUrlTest.php b/tests/phpunit/includes/upload/UploadFromUrlTest.php index 59663ba9f5..307810dc7c 100644 --- a/tests/phpunit/includes/upload/UploadFromUrlTest.php +++ b/tests/phpunit/includes/upload/UploadFromUrlTest.php @@ -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(); diff --git a/tests/phpunit/maintenance/MaintenanceTest.php b/tests/phpunit/maintenance/MaintenanceTest.php index 4a6f08fa4f..a0ed745c12 100644 --- a/tests/phpunit/maintenance/MaintenanceTest.php +++ b/tests/phpunit/maintenance/MaintenanceTest.php @@ -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 +}