*/
class PageArchive {
protected $title;
+ var $fileStatus;
function __construct( $title ) {
if( is_null( $title ) ) {
if( $restoreFiles && $this->title->getNamespace() == NS_IMAGE ) {
$img = wfLocalFile( $this->title );
- $filesRestored = $img->restore( $fileVersions );
+ $this->fileStatus = $img->restore( $fileVersions );
+ $filesRestored = $this->fileStatus->successCount;
} else {
$filesRestored = 0;
}
} else {
$textRestored = 0;
}
-
+
// Touch the log!
global $wgContLang;
$log = new LogPage( 'delete' );
if( trim( $comment ) != '' )
$reason .= ": {$comment}";
$log->addEntry( 'restore', $this->title, $reason );
-
- return true;
+
+ if ( $this->fileStatus && !$this->fileStatus->ok ) {
+ return false;
+ } else {
+ return true;
+ }
}
/**
return $restored;
}
+ function getFileStatus() { return $this->fileStatus; }
}
/**
$logViewer = new LogViewer(
new LogReader(
new FauxRequest(
- array( 'page' => $this->mTargetObj->getPrefixedText(),
- 'type' => 'delete' ) ) ) );
+ array(
+ 'page' => $this->mTargetObj->getPrefixedText(),
+ 'type' => 'delete'
+ )
+ )
+ ), LogViewer::NO_ACTION_LINK
+ );
$logViewer->showList( $wgOut );
if( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) {
$this->mTargetTimestamp,
$this->mComment,
$this->mFileVersions );
-
+
if( $ok ) {
$skin = $wgUser->getSkin();
$link = $skin->makeKnownLinkObj( $this->mTargetObj );
$wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );
- return true;
+ } else {
+ $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
}
+
+ // Show file deletion warnings and errors
+ $status = $archive->getFileStatus();
+ if ( $status && !$status->isGood() ) {
+ $wgOut->addWikiText( $status->getWikiText( 'undelete-error-short', 'undelete-error-long' ) );
+ }
+ } else {
+ $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
}
- $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
return false;
}
}