* Preserve protection on move for original title (now redirect) (bug 10527)
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 24 Sep 2008 15:02:02 +0000 (15:02 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 24 Sep 2008 15:02:02 +0000 (15:02 +0000)
* Add a protection log entry to the new title on page move. Would be nice to have log_params set here too. (bug 8296)

includes/Title.php

index e2be4e7..9cfdba1 100644 (file)
@@ -2572,6 +2572,7 @@ class Title {
                }
 
                $pageid = $this->getArticleID();
+               $protected = $this->isProtected();
                if( $nt->exists() ) {
                        $err = $this->moveOverExistingRedirect( $nt, $reason, $createRedirect );
                        $pageCountChange = ($createRedirect ? 0 : -1);
@@ -2606,8 +2607,28 @@ class Title {
                                'cl_sortkey' => $this->getPrefixedText() ),
                        __METHOD__ );
 
-               # Update watchlists
+               if( $protected ) {
+                       # Protect the redirect title as the title used to be...
+                       $dbw->insertSelect( 'page_restrictions', 'page_restrictions',
+                               array( 
+                                       'pr_page'    => $redirid,
+                                       'pr_type'    => 'pr_type',
+                                       'pr_level'   => 'pr_level',
+                                       'pr_cascade' => 'pr_cascade',
+                                       'pr_user'    => 'pr_user',
+                                       'pr_expiry'  => 'pr_expiry'
+                               ),
+                               array( 'pr_page' => $pageid ),
+                               __METHOD__,
+                               array( 'IGNORE' )
+                       );
+                       # Update the protection log
+                       $log = new LogPage( 'protect' );
+                       $comment = wfMsgForContent('1movedto2',$this->getPrefixedText(), $nt->getPrefixedText() );
+                       $log->addEntry( 'protect', $nt, $comment, array() ); // FIXME: $params?
+               }
 
+               # Update watchlists
                $oldnamespace = $this->getNamespace() & ~1;
                $newnamespace = $nt->getNamespace() & ~1;
                $oldtitle = $this->getDBkey();