* Delete cached transformed files for the current version only.
* @param array $options
*/
- function purgeThumbnails( $options = array() ) {
+ public function purgeThumbnails( $options = array() ) {
global $wgUseSquid;
// Delete thumbnails
$user
);
- $dbw->begin( __METHOD__ ); // XXX; doEdit() uses a transaction
// Now that the page exists, make an RC entry.
+ // This relies on the resetArticleID() call in WikiPage::insertOn(),
+ // which is triggered on $descTitle by doEditContent() above.
$logEntry->publish( $logId );
if ( isset( $status->value['revision'] ) ) {
$dbw->update( 'logging',
__METHOD__
);
}
- $dbw->commit( __METHOD__ ); // commit before anything bad can happen
}
- if ( $reupload ) {
- # Delete old thumbnails
- $this->purgeThumbnails();
-
- # Remove the old file from the squid cache
- SquidUpdate::purge( array( $this->getURL() ) );
- }
-
- # Hooks, hooks, the magic of hooks...
- Hooks::run( 'FileUpload', array( $this, $reupload, $descTitle->exists() ) );
+ # Do some cache purges after final commit so that:
+ # a) Changes are more likely to be seen post-purge
+ # b) They won't cause rollback of the log publish/update above
+ $that = $this;
+ $dbw->onTransactionIdle( function () use ( $that, $reupload, $descTitle ) {
+ # Run hook for other updates (typically more cache purging)
+ Hooks::run( 'FileUpload', array( $that, $reupload, $descTitle->exists() ) );
+
+ if ( $reupload ) {
+ # Delete old thumbnails
+ $that->purgeThumbnails();
+ # Remove the old file from the squid cache
+ SquidUpdate::purge( array( $that->getURL() ) );
+ } else {
+ # Update backlink pages pointing to this title if created
+ LinksUpdate::queueRecursiveJobsForTable( $that->getTitle(), 'imagelinks' );
+ }
+ } );
# Invalidate cache for all pages using this file
- $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
- $update->doUpdate();
- if ( !$reupload ) {
- LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
- }
+ DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' ) );
return true;
}
}
public function run() {
+ /** @noinspection PhpUnusedLocalVariableInspection */
$scope = RequestContext::importScopedSession( $this->params['session'] );
$context = RequestContext::getMain();
$user = $context->getUser();
$upload->continueChunks(
$this->params['filename'],
$this->params['filekey'],
- $context->getRequest()
+ new WebRequestUpload( $context->getRequest(), 'null' )
);
// Combine all of the chunks into a local file and upload that to a new stash file
'status' => Status::newFatal( 'api-error-stashfailed' )
)
);
- $this->setLastError( get_class( $e ) . ": " . $e->getText() );
+ $this->setLastError( get_class( $e ) . ": " . $e->getMessage() );
// To be extra robust.
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
}
public function run() {
+ /** @noinspection PhpUnusedLocalVariableInspection */
$scope = RequestContext::importScopedSession( $this->params['session'] );
$context = RequestContext::getMain();
$user = $context->getUser();
'status' => Status::newFatal( 'api-error-publishfailed' )
)
);
- $this->setLastError( get_class( $e ) . ": " . $e->getText() );
+ $this->setLastError( get_class( $e ) . ": " . $e->getMessage() );
// To prevent potential database referential integrity issues.
// See bug 32551.
MWExceptionHandler::rollbackMasterChangesAndLog( $e );