From c23ccacba320473b6e1f333805f22c8681316429 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 23 Sep 2011 16:15:30 +0000 Subject: [PATCH] * Call Linker methods statically * Moved wfReadOnly() check after permissions so that users don't think the error is temporary if they and don't have permissions and the database is locked * Removed "unexpected value of 'oldimage'" message which seems to say there's an internal error somewhere instead that the oldimage parameter is not in correct format --- includes/FileDeleteForm.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index e2c95c2e0b..e2745e2bac 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -32,27 +32,24 @@ class FileDeleteForm { global $wgOut, $wgRequest, $wgUser; $this->setHeaders(); - if( wfReadOnly() ) { - $wgOut->readOnlyPage(); - return; - } $permission_errors = $this->title->getUserPermissionsErrors('delete', $wgUser); if ( count( $permission_errors ) > 0 ) { $wgOut->showPermissionsErrorPage( $permission_errors ); return; } + if ( wfReadOnly() ) { + throw new ReadOnlyError; + } + $this->oldimage = $wgRequest->getText( 'oldimage', false ); $token = $wgRequest->getText( 'wpEditToken' ); # Flag to hide all contents of the archived revisions $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('suppressrevision'); - if( $this->oldimage && !self::isValidOldSpec($this->oldimage) ) { - $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars( $this->oldimage ) ); - return; - } - if( $this->oldimage ) + if( $this->oldimage ) { $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage ); + } if( !self::haveDeletableFile($this->file, $this->oldfile, $this->oldimage) ) { $wgOut->addHTML( $this->prepareMessage( 'filedelete-nofile' ) ); @@ -220,9 +217,8 @@ class FileDeleteForm { Xml::closeElement( 'form' ); if ( $wgUser->isAllowed( 'editinterface' ) ) { - $skin = $wgUser->getSkin(); $title = Title::makeTitle( NS_MEDIAWIKI, 'Filedelete-reason-dropdown' ); - $link = $skin->link( + $link = Linker::link( $title, wfMsgHtml( 'filedelete-edit-reasonlist' ), array(), @@ -274,18 +270,12 @@ class FileDeleteForm { * Set headers, titles and other bits */ private function setHeaders() { - global $wgOut, $wgUser; + global $wgOut; $wgOut->setPageTitle( wfMsg( 'filedelete', $this->title->getText() ) ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->setSubtitle( wfMsg( 'filedelete-backlink', - $wgUser->getSkin()->link( - $this->title, - null, - array(), - array(), - array( 'known', 'noclasses' ) - ) + Linker::linkKnown( $this->title ) ) ); } -- 2.20.1