From: Brion Vibber Date: Thu, 26 Oct 2006 16:47:30 +0000 (+0000) Subject: * PageArchive can now return a Revision object for more convenient processing X-Git-Tag: 1.31.0-rc.0~55371 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=5608baea84a5efb2bc957cca09c07a82141c3511;p=lhc%2Fweb%2Fwiklou.git * PageArchive can now return a Revision object for more convenient processing of deleted revision data * Added 'UndeleteShowRevision' hook in Special:Undelete * Error message on attempt to view invalid or missing deleted revisions --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 637f0bba7a..cac6b3312d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -92,6 +92,11 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Allow compound interwiki prefixes in $wgImportSources * Added redirect table to store redirect targets. * Added querycachetwo table (similar to querycache but has two titles) +* PageArchive can now return a Revision object for more convenient processing + of deleted revision data +* Added 'UndeleteShowRevision' hook in Special:Undelete +* Error message on attempt to view invalid or missing deleted revisions + == Languages updated == diff --git a/includes/Revision.php b/includes/Revision.php index bd68e05a80..6ef9ede33d 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -297,6 +297,7 @@ class Revision { // Enforce spacing trimming on supplied text $this->mComment = isset( $row['comment'] ) ? trim( strval( $row['comment'] ) ) : null; $this->mText = isset( $row['text'] ) ? rtrim( strval( $row['text'] ) ) : null; + $this->mTextRow = null; $this->mTitle = null; # Load on demand if needed $this->mCurrent = false; diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 8e0291ec87..e07fa95c31 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -105,17 +105,47 @@ class PageArchive { * revision of the page with the given timestamp. * * @return string + * @deprecated Use getRevision() for more flexible information */ function getRevisionText( $timestamp ) { + $rev = $this->getRevision( $timestamp ); + return $rev ? $rev->getText() : null; + } + + /** + * Return a Revision object containing data for the deleted revision. + * Note that the result *may* or *may not* have a null page ID. + * @param string $timestamp + * @return Revision + */ + function getRevision( $timestamp ) { $dbr =& wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'archive', - array( 'ar_text', 'ar_flags', 'ar_text_id' ), + array( + 'ar_rev_id', + 'ar_text', + 'ar_comment', + 'ar_user', + 'ar_user_text', + 'ar_timestamp', + 'ar_minor_edit', + 'ar_flags', + 'ar_text_id' ), array( 'ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDbkey(), 'ar_timestamp' => $dbr->timestamp( $timestamp ) ), __METHOD__ ); if( $row ) { - return $this->getTextFromRow( $row ); + return new Revision( array( + 'page' => $this->title->getArticleId(), + 'id' => $row->ar_rev_id, + 'text' => ($row->ar_text_id ? null : $row->ar_text), + 'comment' => $row->ar_comment, + 'user' => $row->ar_user, + 'user_text' => $row->ar_user_text, + 'timestamp' => $row->ar_timestamp, + 'minor_edit' => $row->ar_minor_edit, + 'text_id' => $row->ar_text_id ) ); } else { return null; } @@ -485,15 +515,22 @@ class UndeleteForm { if(!preg_match("/[0-9]{14}/",$timestamp)) return 0; $archive = new PageArchive( $this->mTargetObj ); - $text = $archive->getRevisionText( $timestamp ); - + $rev = $archive->getRevision( $timestamp ); + $wgOut->setPagetitle( wfMsg( "undeletepage" ) ); $wgOut->addWikiText( "(" . wfMsg( "undeleterevision", $wgLang->date( $timestamp ) ) . ")\n" ); + if( !$rev ) { + $wgOut->addWikiText( wfMsg( 'undeleterevision-missing' ) ); + return; + } + + wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) ); + if( $this->mPreview ) { $wgOut->addHtml( "
\n" ); - $wgOut->addWikiText( $text ); + $wgOut->addWikiText( $rev->getText() ); } $self = Title::makeTitle( NS_SPECIAL, "Undelete" ); @@ -503,7 +540,7 @@ class UndeleteForm { 'readonly' => true, 'cols' => intval( $wgUser->getOption( 'cols' ) ), 'rows' => intval( $wgUser->getOption( 'rows' ) ) ), - $text . "\n" ) . + $rev->getText() . "\n" ) . wfOpenElement( 'div' ) . wfOpenElement( 'form', array( 'method' => 'post', diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index d45c3b3c7c..999e15be27 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1609,6 +1609,8 @@ will not be automatically replaced.', shown in the summary below, along with details of the users who had edited this page before deletion. The actual text of these deleted revisions is only available to administrators.', 'undeleterevision' => "Deleted revision as of $1", +'undeleterevision-missing' => "Invalid or missing revision. You may have a bad link, or the +revision may have been restored or removed from the archive.", 'undeletebtn' => 'Restore', 'undeletereset' => 'Reset', 'undeletecomment' => 'Comment:',