jenkins-bot has submitted this change and it was merged. Change subject: Make LocalFileLockError an error page exception ......................................................................
Make LocalFileLockError an error page exception This presents a better message than a cryptic red exception hash box Bug: T132921 Change-Id: Ie3f358378af54d0348f18cfb1df763a182259906 --- M includes/filerepo/file/LocalFile.php 1 file changed, 13 insertions(+), 7 deletions(-) Approvals: MaxSem: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index c767078..2c846e5 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1920,17 +1920,12 @@ // Also, that would cause contention on INSERT of similarly named rows. $backend = $this->getRepo()->getBackend(); $lockPaths = [ $this->getPath() ]; // represents all versions of the file - $start = microtime( true ); $status = $backend->lockFiles( $lockPaths, LockManager::LOCK_EX, 10 ); - $waited = microtime( true ) - $start; if ( !$status->isGood() ) { if ( $this->lockedOwnTrx ) { $dbw->rollback( __METHOD__ ); } - throw new LocalFileLockError( - "Could not acquire lock for '{$this->getName()}' ($waited sec): " . - $status->getWikiText( false, false, 'en' ) - ); + throw new LocalFileLockError( $status ); } // Release the lock *after* commit to avoid row-level contention $this->locked++; @@ -3047,6 +3042,17 @@ } } -class LocalFileLockError extends Exception { +class LocalFileLockError extends ErrorPageError { + public function __construct( Status $status ) { + parent::__construct( + 'actionfailed', + $status->getMessage() + ); + } + public function report() { + global $wgOut; + $wgOut->setStatusCode( 429 ); + parent::report(); + } } -- To view, visit https://gerrit.wikimedia.org/r/293268 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie3f358378af54d0348f18cfb1df763a182259906 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits