X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSpecialUndelete.php;h=51b71d086553efd18729959d0d4149265d2cccc5;hb=9463b17980147e7e99a6488d6111cb9d1a52f951;hp=06d66a2b85cf2546c81f8cf531700818aae4610d;hpb=4eb1e2c7ee735d11261c620f1ceb4dadd29efa67;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 06d66a2b85..51b71d0865 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -57,7 +57,7 @@ class PageArchive { $title = Title::newFromText( $prefix ); if( $title ) { $ns = $title->getNamespace(); - $encPrefix = $dbr->escapeLike( $title->getDbKey() ); + $encPrefix = $dbr->escapeLike( $title->getDBkey() ); } else { // Prolly won't work too good // @todo handle bare namespace names cleanly? @@ -132,7 +132,7 @@ class PageArchive { 'fa_user', 'fa_user_text', 'fa_timestamp' ), - array( 'fa_name' => $this->title->getDbKey() ), + array( 'fa_name' => $this->title->getDBkey() ), __METHOD__, array( 'ORDER BY' => 'fa_timestamp DESC' ) ); $ret = $dbr->resultObject( $res ); @@ -174,7 +174,7 @@ class PageArchive { 'ar_text_id', 'ar_len' ), array( 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDbkey(), + 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $dbr->timestamp( $timestamp ) ), __METHOD__ ); if( $row ) { @@ -212,7 +212,7 @@ class PageArchive { $row = $dbr->selectRow( 'archive', 'ar_timestamp', array( 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDbkey(), + 'ar_title' => $this->title->getDBkey(), 'ar_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ), __METHOD__, @@ -225,7 +225,7 @@ class PageArchive { array( 'rev_id', 'rev_timestamp' ), array( 'page_namespace' => $this->title->getNamespace(), - 'page_title' => $this->title->getDbkey(), + 'page_title' => $this->title->getDBkey(), 'page_id = rev_page', 'rev_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ), @@ -303,9 +303,6 @@ class PageArchive { return ($n > 0); } - const UNDELETE_NOTHINGRESTORED = 0; // No revisions could be restored - const UNDELETE_NOTAVAIL = -1; // Not all requested revisions are available - const UNDELETE_UNKNOWNERR = -2; // Unknown error /** * Restore the given (or all) text and file revisions for the page. * Once restored, the items will be removed from the archive tables. @@ -315,7 +312,8 @@ class PageArchive { * @param string $comment * @param array $fileVersions * - * @return array(number of revisions restored, number of file versions restored, log reason) on success or UNDELETE_* on failure + * @return array(number of file revisions restored, number of image revisions restored, log message) + * on success, false on failure */ function undelete( $timestamps, $comment = '', $fileVersions = array() ) { // If both the set of text revisions and file revisions are empty, @@ -335,8 +333,8 @@ class PageArchive { if( $restoreText ) { $textRestored = $this->undeleteRevisions( $timestamps ); - if($textRestored < 0) // It must be one of UNDELETE_* - return $textRestored; + if($textRestored === false) // It must be one of UNDELETE_* + return false; } else { $textRestored = 0; } @@ -357,7 +355,7 @@ class PageArchive { $wgContLang->formatNum( $filesRestored ) ); } else { wfDebug( "Undelete: nothing undeleted...\n" ); - return self::UNDELETE_NOTHINGRESTORED; + return false; } if( trim( $comment ) != '' ) @@ -376,10 +374,11 @@ class PageArchive { * @param string $comment * @param array $fileVersions * - * @return int number of revisions restored on success or UNDELETE_* on failure + * @return mixed number of revisions restored or false on failure */ private function undeleteRevisions( $timestamps ) { - if ( wfReadOnly() ) return 0; + if ( wfReadOnly() ) + return false; $restoreAll = empty( $timestamps ); @@ -432,6 +431,7 @@ class PageArchive { 'ar_minor_edit', 'ar_flags', 'ar_text_id', + 'ar_page_id', 'ar_len' ), /* WHERE */ array( 'ar_namespace' => $this->title->getNamespace(), @@ -443,7 +443,7 @@ class PageArchive { ); if( $dbw->numRows( $result ) < count( $timestamps ) ) { wfDebug( __METHOD__.": couldn't find all requested rows\n" ); - return self::UNDELETE_NOTAVAIL; + return false; } $revision = null; @@ -476,6 +476,8 @@ class PageArchive { ) ); $revision->insertOn( $dbw ); $restored++; + + wfRunHooks( 'ArticleRevisionUndeleted', array( &$this->title, $revision, $row->ar_page_id ) ); } // Was anything restored at all? if($restored == 0) @@ -497,6 +499,11 @@ class PageArchive { wfRunHooks( 'ArticleUndelete', array( &$this->title, false ) ); Article::onArticleEdit( $this->title ); } + + if( $this->title->getNamespace() == NS_IMAGE ) { + $update = new HTMLCacheUpdate( $this->title, 'imagelinks' ); + $update->doUpdate(); + } } else { // Revision couldn't be created. This is very weird return self::UNDELETE_UNKNOWNERR; @@ -607,7 +614,7 @@ class UndeleteForm { function showSearchForm() { global $wgOut, $wgScript; - $wgOut->addWikiText( wfMsg( 'undelete-header' ) ); + $wgOut->addWikiMsg( 'undelete-header' ); $wgOut->addHtml( Xml::openElement( 'form', array( @@ -630,11 +637,11 @@ class UndeleteForm { global $wgLang, $wgContLang, $wgUser, $wgOut; if( $result->numRows() == 0 ) { - $wgOut->addWikiText( wfMsg( 'undelete-no-results' ) ); + $wgOut->addWikiMsg( 'undelete-no-results' ); return; } - $wgOut->addWikiText( wfMsg( "undeletepagetext" ) ); + $wgOut->addWikiMsg( "undeletepagetext" ); $sk = $wgUser->getSkin(); $undelete = SpecialPage::getTitleFor( 'Undelete' ); @@ -665,7 +672,7 @@ class UndeleteForm { $rev = $archive->getRevision( $timestamp ); if( !$rev ) { - $wgOut->addWikiTexT( wfMsg( 'undeleterevision-missing' ) ); + $wgOut->addWikiMsg( 'undeleterevision-missing' ); return; } @@ -835,14 +842,14 @@ class UndeleteForm { /* $text = $archive->getLastRevisionText(); if( is_null( $text ) ) { - $wgOut->addWikiText( wfMsg( "nohistory" ) ); + $wgOut->addWikiMsg( "nohistory" ); return; } */ if ( $this->mAllowed ) { - $wgOut->addWikiText( wfMsg( "undeletehistory" ) ); + $wgOut->addWikiMsg( "undeletehistory" ); } else { - $wgOut->addWikiText( wfMsg( "undeletehistorynoadmin" ) ); + $wgOut->addWikiMsg( "undeletehistorynoadmin" ); } # List all stored revisions @@ -976,7 +983,7 @@ class UndeleteForm { $revisions->free(); $wgOut->addHTML(""); } else { - $wgOut->addWikiText( wfMsg( "nohistory" ) ); + $wgOut->addWikiMsg( "nohistory" ); } if( $haveFiles ) { @@ -1035,6 +1042,10 @@ class UndeleteForm { function undelete() { global $wgOut, $wgUser; + if ( wfReadOnly() ) { + $wgOut->readOnlyPage(); + return; + } if( !is_null( $this->mTargetObj ) ) { $archive = new PageArchive( $this->mTargetObj ); @@ -1044,6 +1055,11 @@ class UndeleteForm { $this->mFileVersions ); if( is_array($ok) ) { + if ( $ok[1] ) // Undeleted file count + wfRunHooks( 'FileUndeleteComplete', array( + $this->mTargetObj, $this->mFileVersions, + $wgUser, $this->mComment) ); + $skin = $wgUser->getSkin(); $link = $skin->makeKnownLinkObj( $this->mTargetObj ); $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );