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.
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',
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' ) ) {
'pageStatus' => $pageStatus
);
$job = new EnotifNotifyJob( $title, $params );
- $job->insert();
+ JobQueueGroup::singleton()->push( $job );
} else {
$this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $pageStatus );
}
$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;
}
'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 ) {
$params = $this->params;
$params['lives']--;
$job = new self( $this->title, $params );
- $job->insert();
+ JobQueueGroup::singleton()->push( $job );
}
return true;
}
/**
* 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;
}
'sessionKey' => $sessionKey,
) );
$job->initializeSessionData();
- $job->insert();
+ JobQueueGroup::singleton()->push( $job );
return $sessionKey;
}
if ( $wgDisableLangConversion ) {
return $text;
}
+ // Reset converter state for a new converter run.
+ $this->mConvRuleTitle = false;
return $this->recursiveConvertTopLevel( $text, $variant );
}
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 );
}
}
* @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.
$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
$this->markTestSkipped( 'Neither the hash nor mhash extension is available' );
return;
}
+ parent::setUp();
}
/**
* 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;
}
}
* 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 );
}
$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' );
}
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' );
'token' => $token,
), $data );
- $job = Job::pop();
+ $job = JobQueueGroup::singleton()->pop();
$this->assertFalse( $job );
$this->assertEquals( 'Success', $data[0]['upload']['result'] );
'ignorewarnings' => 1,
) );
- $job = Job::pop();
+ $job = JobQueueGroup::singleton()->pop();
$this->assertEquals( 'UploadFromUrlJob', get_class( $job ) );
$job->run();
}
$this->assertTrue( $exception );
- $job = Job::pop();
+ $job = JobQueueGroup::singleton()->pop();
$this->assertFalse( $job );
return;
$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();
* 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 :(
$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
"Output before shutdown simulation" );
$this->m->simulateShutdown();
+ $this->m = null;
$postShutdownOutput = $preShutdownOutput . ( $expectNLAppending ? "\n" : "" );
$this->expectOutputString( $postShutdownOutput );
}
-}
\ No newline at end of file
+}