* Returnto now works with special pages with subpage parameters
[lhc/web/wiklou.git] / includes / SpecialUndelete.php
index 36d3669..7a322db 100644 (file)
@@ -4,21 +4,21 @@
  * Special page allowing users with the appropriate permissions to view
  * and restore deleted content
  *
- * @addtogroup Special pages
+ * @addtogroup SpecialPage
  */
 
 /**
- *
+ * Constructor
  */
 function wfSpecialUndelete( $par ) {
-    global $wgRequest;
+       global $wgRequest;
 
        $form = new UndeleteForm( $wgRequest, $par );
        $form->execute();
 }
 
 /**
- * @todo document (just needs one-sentence top-level class description)
+ * Used to show archived pages and eventually restore them.
  * @addtogroup SpecialPage
  */
 class PageArchive {
@@ -319,8 +319,6 @@ class PageArchive {
         * @return int number of revisions restored
         */
        private function undeleteRevisions( $timestamps ) {
-               global $wgDBtype;
-
                $restoreAll = empty( $timestamps );
                
                $dbw = wfGetDB( DB_MASTER );
@@ -328,9 +326,7 @@ class PageArchive {
 
                # Does this page already exist? We'll have to update it...
                $article = new Article( $this->title );
-               $options = ( $wgDBtype == 'postgres' )
-                       ? '' // pg doesn't support this?
-                       : 'FOR UPDATE';
+               $options = 'FOR UPDATE';
                $page = $dbw->selectRow( 'page',
                        array( 'page_id', 'page_latest' ),
                        array( 'page_namespace' => $this->title->getNamespace(),
@@ -422,11 +418,10 @@ class PageArchive {
                }
 
                if( $revision ) {
-                       # FIXME: Update latest if newer as well...
-                       if( $newid ) {
-                               // Attach the latest revision to the page...
-                               $article->updateRevisionOn( $dbw, $revision, $previousRevId );
-                               
+                       // Attach the latest revision to the page...
+                       $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId );
+
+                       if( $newid || $wasnew ) {
                                // Update site stats, link tables, etc
                                $article->createUpdates( $revision );
                        }
@@ -617,7 +612,7 @@ class UndeleteForm {
                
                if( $this->mPreview ) {
                        $wgOut->addHtml( "<hr />\n" );
-                       $wgOut->addWikiTextTitle( $rev->getText(), $this->mTargetObj, false );
+                       $wgOut->addWikiTextTitleTidy( $rev->getText(), $this->mTargetObj, false );
                }
 
                $wgOut->addHtml(