(bug 16950) Show move log when recreating a page
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 24 Apr 2009 17:20:48 +0000 (17:20 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 24 Apr 2009 17:20:48 +0000 (17:20 +0000)
Showing the move log as well as delete log helps with pages that were
moved with no redirect, or moved and then the redirect deleted with a
confusing message.  Previously, such pages would appear to have never
existed to a user trying to create them.

Patch by church of emacs, with trivial modifications by me.

RELEASE-NOTES
includes/Article.php
includes/EditPage.php
includes/LogEventsList.php
languages/messages/MessagesEn.php

index 0d9b0a4..3476fd0 100644 (file)
@@ -171,6 +171,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   to Special:Version
 * Added $wgExtPGAlteredFields to allow extensions to easily alter the data 
   type of columns when using the Postgres backend.
+* (bug 16950) Show move log when viewing/creating a deleted page
 
 
 === Bug fixes in 1.15 ===
index 339199e..eaa4bc2 100644 (file)
@@ -883,9 +883,9 @@ class Article {
                }
                # Fetch content and check for errors
                if( !$outputDone ) {
-                       # If the article does not exist and was deleted, show the log
+                       # If the article does not exist and was deleted/moved, show the log
                        if( $this->getID() == 0 ) {
-                               $this->showDeletionLog();
+                               $this->showLogs();
                        }
                        $text = $this->getContent();
                        // For now, check also for ID until getContent actually returns
@@ -1062,14 +1062,14 @@ class Article {
                wfProfileOut( __METHOD__ );
        }
        
-       protected function showDeletionLog() {
+       protected function showLogs() {
                global $wgUser, $wgOut;
                $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
-               $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
+               $pager = new LogPager( $loglist, array('move', 'delete'), false, $this->mTitle->getPrefixedText() );
                if( $pager->getNumRows() > 0 ) {
                        $pager->mLimit = 10;
                        $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' );
-                       $wgOut->addWikiMsg( 'deleted-notice' );
+                       $wgOut->addWikiMsg( 'moveddeleted-notice' );
                        $wgOut->addHTML(
                                $loglist->beginLogEventsList() .
                                $pager->getBody() .
@@ -1078,9 +1078,9 @@ class Article {
                        if( $pager->getNumRows() > 10 ) {
                                $wgOut->addHTML( $wgUser->getSkin()->link(
                                        SpecialPage::getTitleFor( 'Log' ),
-                                       wfMsgHtml( 'deletelog-fulllog' ),
+                                       wfMsgHtml( 'log-fulllog' ),
                                        array(),
-                                       array( 'type' => 'delete', 'page' => $this->mTitle->getPrefixedText() ) 
+                                       array( 'page' => $this->mTitle->getPrefixedText() ) 
                                ) );
                        }
                        $wgOut->addHTML( '</div>' );
index 3589b52..6dbee62 100644 (file)
@@ -707,9 +707,9 @@ class EditPage {
                                $wgOut->wrapWikiMsg( '<div class="mw-newarticletextanon">$1</div>', 'newarticletextanon' );
                        }
                }
-               # Give a notice if the user is editing a deleted page...
+               # Give a notice if the user is editing a deleted/moved page...
                if ( !$this->mTitle->exists() ) {
-                       $this->showDeletionLog( $wgOut );
+                       $this->showLogs( $wgOut );
                }
        }
 
@@ -2435,20 +2435,20 @@ END
        }
 
        /**
-        * If there are rows in the deletion log for this page, show them,
+        * If there are rows in the deletion/move log for this page, show them,
         * along with a nice little note for the user
         *
         * @param OutputPage $out
         */
-       protected function showDeletionLog( $out ) {
+       protected function showLogs( $out ) {
                global $wgUser;
                $loglist = new LogEventsList( $wgUser->getSkin(), $out );
-               $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
+               $pager = new LogPager( $loglist, array('move', 'delete'), false, $this->mTitle->getPrefixedText() );
                $count = $pager->getNumRows();
                if ( $count > 0 ) {
                        $pager->mLimit = 10;
                        $out->addHTML( '<div class="mw-warning-with-logexcerpt">' );
-                       $out->addWikiMsg( 'recreate-deleted-warn' );
+                       $out->addWikiMsg( 'recreate-moveddeleted-warn' );
                        $out->addHTML(
                                $loglist->beginLogEventsList() .
                                $pager->getBody() .
@@ -2457,11 +2457,9 @@ END
                        if($count > 10){
                                $out->addHTML( $wgUser->getSkin()->link(
                                        SpecialPage::getTitleFor( 'Log' ),
-                                       wfMsgHtml( 'deletelog-fulllog' ),
+                                       wfMsgHtml( 'log-fulllog' ),
                                        array(),
-                                       array(
-                                               'type' => 'delete',
-                                               'page' => $this->mTitle->getPrefixedText() ) ) );
+                                       array( 'page' => $this->mTitle->getPrefixedText() ) ) );
                        }
                        $out->addHTML( '</div>' );
                        return true;
index 8baf12e..7acebc0 100644 (file)
@@ -541,24 +541,28 @@ class LogPager extends ReverseChronologicalPager {
        /**
         * Set the log reader to return only entries of the given type.
         * Type restrictions enforced here
-        * @param $type String: A log type ('upload', 'delete', etc)
+        * @param $type String or array: Log types ('upload', 'delete', etc)
         */
-       private function limitType( $type ) {
+       private function limitType( $types ) {
                global $wgLogRestrictions, $wgUser;
+               // If $types is not an array, make it an array
+               $types = (array)$types;
                // Don't even show header for private logs; don't recognize it...
-               if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
-                       $type = '';
+               foreach ( $types as $type ) {
+                       if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
+                               $types = array_diff( $types, array( $type ) );
+                       }
                }
-               // Don't show private logs to unpriviledged users.
+               // Don't show private logs to unprivileged users.
                // Also, only show them upon specific request to avoid suprises.
-               $audience = $type ? 'user' : 'public';
+               $audience = $types ? 'user' : 'public';
                $hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience );
                if( $hideLogs !== false ) {
                        $this->mConds[] = $hideLogs;
                }
-               if( $type ) {
-                       $this->type = $type;
-                       $this->mConds['log_type'] = $type;
+               if( $types ) {
+                       $this->type = $types;
+                       $this->mConds['log_type'] = $types;
                }
        }
 
index 0eadd8d..77d4637 100644 (file)
@@ -1213,13 +1213,13 @@ You can go back and edit an existing page, or [[Special:UserLogin|log in or crea
 'permissionserrors'                => 'Permissions Errors',
 'permissionserrorstext'            => 'You do not have permission to do that, for the following {{PLURAL:$1|reason|reasons}}:',
 'permissionserrorstext-withaction' => 'You do not have permission to $2, for the following {{PLURAL:$1|reason|reasons}}:',
-'recreate-deleted-warn'            => "'''Warning: You are recreating a page that was previously deleted.'''
+'recreate-moveddeleted-warn'       => "'''Warning: You are recreating a page that was previously deleted.'''
 
 You should consider whether it is appropriate to continue editing this page.
-The deletion log for this page is provided here for convenience:",
-'deleted-notice'                   => 'This page has been deleted.
-The deletion log for the page is provided below for reference.',
-'deletelog-fulllog'                => 'View full log',
+The deletion and move log for this page are provided here for convenience:",
+'moveddeleted-notice'              => 'This page has been deleted.
+The deletion and move log for the page are provided below for reference.',
+'log-fulllog'                      => 'View full log',
 'edit-hook-aborted'                => 'Edit aborted by hook.
 It gave no explanation.',
 'edit-gone-missing'                => 'Could not update the page.