* PageArchive can now return a Revision object for more convenient processing
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 26 Oct 2006 16:47:30 +0000 (16:47 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 26 Oct 2006 16:47:30 +0000 (16:47 +0000)
  of deleted revision data
* Added 'UndeleteShowRevision' hook in Special:Undelete
* Error message on attempt to view invalid or missing deleted revisions

RELEASE-NOTES
includes/Revision.php
includes/SpecialUndelete.php
languages/messages/MessagesEn.php

index 637f0bb..cac6b33 100644 (file)
@@ -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 ==
 
index bd68e05..6ef9ede 100644 (file)
@@ -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;
index 8e0291e..e07fa95 100644 (file)
@@ -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( "<hr />\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',
index d45c3b3..999e15b 100644 (file)
@@ -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:',