X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=9d6ab6509a9c31b3c8b65103674a333cf24884b2;hb=2f5914c2ce4c612920dd96f5ef66e3bd342d2195;hp=fcf410529420676611d0a34d719ac000c670a8a4;hpb=29e81897f9ee1a807b95e5b59f6106f1123b1ff3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index fcf4105294..9d6ab6509a 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -1,10 +1,31 @@ + * @ingroup Media + */ /** * File deletion user interface * * @ingroup Media - * @author Rob Church */ class FileDeleteForm { @@ -89,9 +110,7 @@ class FileDeleteForm { if( !$status->isGood() ) { $wgOut->addHTML( '

' . $this->prepareMessage( 'filedeleteerror-short' ) . "

\n" ); - $wgOut->addHTML( '' ); - $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) ); - $wgOut->addHTML( '' ); + $wgOut->addWikiText( '
' . $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) . '
' ); } if( $status->ok ) { $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) ); @@ -101,9 +120,9 @@ class FileDeleteForm { $wgOut->addReturnTo( $this->oldimage ? $this->title : Title::newMainPage() ); if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { - WatchAction::doWatch( $title, $wgUser ); + WatchAction::doWatch( $this->title, $wgUser ); } elseif ( $this->title->userIsWatching() ) { - WatchAction::doUnwatch( $title, $wgUser ); + WatchAction::doUnwatch( $this->title, $wgUser ); } } return; @@ -117,11 +136,12 @@ class FileDeleteForm { * Really delete the file * * @param $title Title object - * @param $file File object + * @param File $file: file object * @param $oldimage String: archive name * @param $reason String: reason of the deletion * @param $suppress Boolean: whether to mark all deleted versions as restricted * @param $user User object performing the request + * @return bool|Status */ public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress, User $user = null ) { if ( $user === null ) { @@ -142,29 +162,30 @@ class FileDeleteForm { $log->addEntry( 'delete', $title, $logComment ); } } else { - $status = Status::newFatal( 'error' ); - $id = $title->getArticleID( Title::GAID_FOR_UPDATE ); + $status = Status::newFatal( 'cannotdelete', + wfEscapeWikiText( $title->getPrefixedText() ) + ); $page = WikiPage::factory( $title ); $dbw = wfGetDB( DB_MASTER ); try { // delete the associated article first $error = ''; - if ( $page->doDeleteArticle( $reason, $suppress, $id, false, $error, $user ) ) { + if ( $page->doDeleteArticleReal( $reason, $suppress, 0, false, $error, $user ) >= WikiPage::DELETE_SUCCESS ) { $status = $file->delete( $reason, $suppress ); - if( $status->ok ) { - $dbw->commit(); + if( $status->isOK() ) { + $dbw->commit( __METHOD__ ); } else { - $dbw->rollback(); + $dbw->rollback( __METHOD__ ); } } } catch ( MWException $e ) { // rollback before returning to prevent UI from displaying incorrect "View or restore N deleted edits?" - $dbw->rollback(); + $dbw->rollback( __METHOD__ ); throw $e; } } - if ( $status->isGood() ) { + if ( $status->isOK() ) { wfRunHooks( 'FileDeleteComplete', array( &$file, &$oldimage, &$page, &$user, &$reason ) ); } @@ -258,7 +279,7 @@ class FileDeleteForm { */ private function showLogEntries() { global $wgOut; - $wgOut->addHTML( '

' . htmlspecialchars( LogPage::getName( 'delete' ) ) . "

\n" ); + $wgOut->addHTML( '

' . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\n" ); LogEventsList::showLogExtract( $wgOut, 'delete', $this->title ); }