(no commit message)
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 31 Jul 2008 02:28:49 +0000 (02:28 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 31 Jul 2008 02:28:49 +0000 (02:28 +0000)
includes/Article.php
includes/EditPage.php
languages/messages/MessagesEn.php
maintenance/archives/patch-rd_fragment.sql [new file with mode: 0644]
maintenance/archives/patch-rd_interwiki.sql [new file with mode: 0644]
maintenance/tables.sql
maintenance/updaters.inc

index a01469d..58abadd 100644 (file)
@@ -103,7 +103,9 @@ class Article {
                $dbw->replace('redirect', array('rd_from'), array(
                                'rd_from' => $this->getID(),
                                'rd_namespace' => $retval->getNamespace(),
-                               'rd_title' => $retval->getDBKey()
+                               'rd_title' => $retval->getDBKey(),
+                               'rd_interwiki' => $retval->getInterwiki(),
+                               'rd_fragment'  => $retval->getFragment(),
                ), __METHOD__);
                return $retval;
        }
@@ -1182,6 +1184,8 @@ class Article {
                                        'rd_namespace' => $redirectTitle->getNamespace(),
                                        'rd_title'     => $redirectTitle->getDBkey(),
                                        'rd_from'      => $this->getId(),
+                                       'rd_interwiki' => $redirectTitle->getInterwiki(),
+                                       'rd_fragment'  => $redirectTitle->getFragment(),
                                );
 
                                $dbw->replace( 'redirect', array( 'rd_from' ), $set, __METHOD__ );
index 585e156..83aa90b 100644 (file)
@@ -41,6 +41,7 @@ class EditPage {
        const AS_SPAM_ERROR                     = 232;
        const AS_IMAGE_REDIRECT_ANON            = 233;
        const AS_IMAGE_REDIRECT_LOGGED          = 234;
+       const AS_DOUBLE_REDIRECT            = 235;
 
        var $mArticle;
        var $mTitle;
@@ -58,6 +59,7 @@ class EditPage {
        var $kblength = false;
        var $missingComment = false;
        var $missingSummary = false;
+       var $doubleRedirect = false;
        var $allowBlankSummary = false;
        var $autoSumm = '';
        var $hookError = '';
@@ -927,6 +929,11 @@ class EditPage {
                        return self::AS_HOOK_ERROR;
                }
 
+               # Are we creating a double redirect?
+               if ( $redirectTitle = Title::newFromRedirect( $this->textbox1 ) && $redirectTitle->isRedirect() ) {
+                       $this->doubleRedirect = $redirectTitle;
+               }
+
                # Handle the user preference to force summaries here, but not for null edits
                if( $this->section != 'new' && !$this->allowBlankSummary &&  $wgUser->getOption( 'forceeditsummary') && 
                        0 != strcmp($oldtext, $text) && 
@@ -1087,6 +1094,11 @@ class EditPage {
                                $wgOut->wrapWikiMsg( '<div id="mw-missingcommenttext">$1</div>',  'missingcommenttext' );
                        }
 
+                       if ( $this->doubleRedirect instanceof Title ) {
+                               $wgOut->wrapWikiMsg( '<div id="mw-creatingdoubleredirect">$1</div>', 
+                                                       array( 'creatingdoubleredirect', $this->mTitle->getText(), $this->doubleRedirect->getText() ) );
+                       }
+
                        if( $this->missingSummary && $this->section != 'new' ) {
                                $wgOut->wrapWikiMsg( '<div id="mw-missingsummary">$1</div>', 'missingsummary' );
                        }
@@ -1361,6 +1373,9 @@ END
                        // mode will show an extra newline. A bit annoying.
                        $encodedtext .= "\n";
                }
+               if ( $this->doubleRedirect instanceof Title ) {
+                       $wgOut->addHTML( Xml::hidden( 'wpIgnoreDoubleRedirect', true ) );
+               }
 
                $wgOut->addHTML( <<<END
 $recreate
index 7f7534a..c76fe62 100644 (file)
@@ -1034,6 +1034,8 @@ If you click Save again, your edit will be saved without one.",
 'missingcommenttext'               => 'Please enter a comment below.',
 'missingcommentheader'             => "'''Reminder:''' You have not provided a subject/headline for this comment.
 If you click Save again, your edit will be saved without one.",
+'creatingdoubleredirect'           => "'''Caution:''' You are attempting to redirect this page to [[$1]], but it redirects to 
+[[$2]]. Redirects that redirect two or more times do not work.",
 'summary-preview'                  => 'Summary preview',
 'subject-preview'                  => 'Subject/headline preview',
 'blockedtitle'                     => 'User is blocked',
diff --git a/maintenance/archives/patch-rd_fragment.sql b/maintenance/archives/patch-rd_fragment.sql
new file mode 100644 (file)
index 0000000..ec22854
--- /dev/null
@@ -0,0 +1,4 @@
+-- Add fragment (section link) column to redirect table
+
+ALTER TABLE /*$wgDBprefix*/redirect
+   ADD rd_fragment varchar(255) binary DEFAULT NULL;
\ No newline at end of file
diff --git a/maintenance/archives/patch-rd_interwiki.sql b/maintenance/archives/patch-rd_interwiki.sql
new file mode 100644 (file)
index 0000000..a99d8b4
--- /dev/null
@@ -0,0 +1,4 @@
+-- Add interwiki column to redirect table
+
+ALTER TABLE /*$wgDBprefix*/redirect
+   ADD rd_interwiki varchar(32) default NULL;
\ No newline at end of file
index 11ed7cb..31b47cd 100644 (file)
@@ -1157,6 +1157,8 @@ CREATE TABLE /*$wgDBprefix*/redirect (
   -- goes by.
   rd_namespace int NOT NULL default '0',
   rd_title varchar(255) binary NOT NULL default '',
+  rd_interwiki varchar(32) default NULL,
+  rd_fragment varchar(255) binary DEFAULT NULL,
 
   PRIMARY KEY rd_from (rd_from),
   KEY rd_ns_title (rd_namespace,rd_title,rd_from)
index b121f2f..f1693a2 100644 (file)
@@ -143,6 +143,10 @@ $wgMysqlUpdates = array(
        array( 'maybe_do_profiling_memory_update' ),
        array( 'do_filearchive_indices_update' ),
        array( 'update_password_format' ),
+       
+       // 1.14
+       array( 'add_field', 'redirect',      'rd_interwiki',     'patch-rd_interwiki.sql' ),
+       array( 'add_field', 'redirect',      'rd_fragment',      'patch-rd_fragment.sql'  ),
 );
 
 
@@ -1716,3 +1720,4 @@ function do_postgres_updates() {
        return;
 }
 
+