Index: branches/wmf/1.17wmf1/includes/Article.php |
— | — | @@ -95,16 +95,13 @@ |
96 | 96 | # Query the redirect table |
97 | 97 | $dbr = wfGetDB( DB_SLAVE ); |
98 | 98 | $row = $dbr->selectRow( 'redirect', |
99 | | - array( 'rd_namespace', 'rd_title', 'rd_fragment', 'rd_interwiki' ), |
| 99 | + array( 'rd_namespace', 'rd_title' ), |
100 | 100 | array( 'rd_from' => $this->getID() ), |
101 | 101 | __METHOD__ |
102 | 102 | ); |
103 | 103 | |
104 | | - // rd_fragment and rd_interwiki were added later, populate them if empty |
105 | | - if ( $row && !is_null( $row->rd_fragment ) && !is_null( $row->rd_interwiki ) ) { |
106 | | - return $this->mRedirectTarget = Title::makeTitle( |
107 | | - $row->rd_namespace, $row->rd_title, |
108 | | - $row->rd_fragment, $row->rd_interwiki ); |
| 104 | + if ( $row ) { |
| 105 | + return $this->mRedirectTarget = Title::makeTitle( $row->rd_namespace, $row->rd_title ); |
109 | 106 | } |
110 | 107 | |
111 | 108 | # This page doesn't have an entry in the redirect table |
— | — | @@ -115,44 +112,36 @@ |
116 | 113 | * Insert an entry for this page into the redirect table. |
117 | 114 | * |
118 | 115 | * Don't call this function directly unless you know what you're doing. |
119 | | - * @return Title object or null if not a redirect |
| 116 | + * @return Title object |
120 | 117 | */ |
121 | 118 | public function insertRedirect() { |
122 | | - // recurse through to only get the final target |
123 | | - $retval = Title::newFromRedirectRecurse( $this->getContent() ); |
| 119 | + $retval = Title::newFromRedirect( $this->getContent() ); |
| 120 | + |
124 | 121 | if ( !$retval ) { |
125 | 122 | return null; |
126 | 123 | } |
127 | | - $this->insertRedirectEntry( $retval ); |
128 | | - return $retval; |
129 | | - } |
130 | | - |
131 | | - /** |
132 | | - * Insert or update the redirect table entry for this page to indicate |
133 | | - * it redirects to $rt . |
134 | | - * @param $rt Title redirect target |
135 | | - */ |
136 | | - public function insertRedirectEntry( $rt ) { |
| 124 | + |
137 | 125 | $dbw = wfGetDB( DB_MASTER ); |
138 | 126 | $dbw->replace( 'redirect', array( 'rd_from' ), |
139 | 127 | array( |
140 | 128 | 'rd_from' => $this->getID(), |
141 | | - 'rd_namespace' => $rt->getNamespace(), |
142 | | - 'rd_title' => $rt->getDBkey(), |
143 | | - 'rd_fragment' => $rt->getFragment(), |
144 | | - 'rd_interwiki' => $rt->getInterwiki(), |
| 129 | + 'rd_namespace' => $retval->getNamespace(), |
| 130 | + 'rd_title' => $retval->getDBkey() |
145 | 131 | ), |
146 | 132 | __METHOD__ |
147 | 133 | ); |
| 134 | + |
| 135 | + return $retval; |
148 | 136 | } |
149 | 137 | |
150 | 138 | /** |
151 | | - * Get the Title object or URL this page redirects to |
| 139 | + * Get the Title object this page redirects to |
152 | 140 | * |
153 | 141 | * @return mixed false, Title of in-wiki target, or string with URL |
154 | 142 | */ |
155 | 143 | public function followRedirect() { |
156 | | - return $this->getRedirectURL( $this->getRedirectTarget() ); |
| 144 | + $text = $this->getContent(); |
| 145 | + return $this->followRedirectText( $text ); |
157 | 146 | } |
158 | 147 | |
159 | 148 | /** |
— | — | @@ -160,21 +149,11 @@ |
161 | 150 | * |
162 | 151 | * @param $text string article content containing redirect info |
163 | 152 | * @return mixed false, Title of in-wiki target, or string with URL |
164 | | - * @deprecated |
165 | 153 | */ |
166 | 154 | public function followRedirectText( $text ) { |
167 | 155 | // recurse through to only get the final target |
168 | | - return $this->getRedirectURL( Title::newFromRedirectRecurse( $text ) ); |
169 | | - } |
170 | | - |
171 | | - /** |
172 | | - * Get the Title object or URL to use for a redirect. We use Title |
173 | | - * objects for same-wiki, non-special redirects and URLs for everything |
174 | | - * else. |
175 | | - * @param $rt Title Redirect target |
176 | | - * @return mixed false, Title object of local target, or string with URL |
177 | | - */ |
178 | | - public function getRedirectURL( $rt ) { |
| 156 | + $rt = Title::newFromRedirectRecurse( $text ); |
| 157 | + |
179 | 158 | if ( $rt ) { |
180 | 159 | if ( $rt->getInterwiki() != '' ) { |
181 | 160 | if ( $rt->isLocal() ) { |
— | — | @@ -1780,7 +1759,7 @@ |
1781 | 1760 | wfProfileIn( __METHOD__ ); |
1782 | 1761 | |
1783 | 1762 | $text = $revision->getText(); |
1784 | | - $rt = Title::newFromRedirectRecurse( $text ); |
| 1763 | + $rt = Title::newFromRedirect( $text ); |
1785 | 1764 | |
1786 | 1765 | $conditions = array( 'page_id' => $this->getId() ); |
1787 | 1766 | |
— | — | @@ -1829,7 +1808,13 @@ |
1830 | 1809 | if ( $isRedirect || is_null( $lastRevIsRedirect ) || $lastRevIsRedirect !== $isRedirect ) { |
1831 | 1810 | wfProfileIn( __METHOD__ ); |
1832 | 1811 | if ( $isRedirect ) { |
1833 | | - $this->insertRedirectEntry( $redirectTitle ); |
| 1812 | + // This title is a redirect, Add/Update row in the redirect table |
| 1813 | + $set = array( /* SET */ |
| 1814 | + 'rd_namespace' => $redirectTitle->getNamespace(), |
| 1815 | + 'rd_title' => $redirectTitle->getDBkey(), |
| 1816 | + 'rd_from' => $this->getId(), |
| 1817 | + ); |
| 1818 | + $dbw->replace( 'redirect', array( 'rd_from' ), $set, __METHOD__ ); |
1834 | 1819 | } else { |
1835 | 1820 | // This is not a redirect, remove row from redirect table |
1836 | 1821 | $where = array( 'rd_from' => $this->getId() ); |
Index: branches/wmf/1.17wmf1/includes/Title.php |
— | — | @@ -273,12 +273,11 @@ |
274 | 274 | * @param $ns \type{\int} the namespace of the article |
275 | 275 | * @param $title \type{\string} the unprefixed database key form |
276 | 276 | * @param $fragment \type{\string} The link fragment (after the "#") |
277 | | - * @param $interwiki \type{\string} The interwiki prefix |
278 | 277 | * @return \type{Title} the new object |
279 | 278 | */ |
280 | | - public static function &makeTitle( $ns, $title, $fragment = '', $interwiki = '' ) { |
| 279 | + public static function &makeTitle( $ns, $title, $fragment = '' ) { |
281 | 280 | $t = new Title(); |
282 | | - $t->mInterwiki = $interwiki; |
| 281 | + $t->mInterwiki = ''; |
283 | 282 | $t->mFragment = $fragment; |
284 | 283 | $t->mNamespace = $ns = intval( $ns ); |
285 | 284 | $t->mDbkeyform = str_replace( ' ', '_', $title ); |
— | — | @@ -296,12 +295,11 @@ |
297 | 296 | * @param $ns \type{\int} the namespace of the article |
298 | 297 | * @param $title \type{\string} the database key form |
299 | 298 | * @param $fragment \type{\string} The link fragment (after the "#") |
300 | | - * @param $interwiki \type{\string} The interwiki prefix |
301 | 299 | * @return \type{Title} the new object, or NULL on an error |
302 | 300 | */ |
303 | | - public static function makeTitleSafe( $ns, $title, $fragment = '', $interwiki = '' ) { |
| 301 | + public static function makeTitleSafe( $ns, $title, $fragment = '' ) { |
304 | 302 | $t = new Title(); |
305 | | - $t->mDbkeyform = Title::makeName( $ns, $title, $fragment, $interwiki ); |
| 303 | + $t->mDbkeyform = Title::makeName( $ns, $title, $fragment ); |
306 | 304 | if ( $t->secureAndSplit() ) { |
307 | 305 | return $t; |
308 | 306 | } else { |
— | — | @@ -499,17 +497,13 @@ |
500 | 498 | * @param $ns \type{\int} numerical representation of the namespace |
501 | 499 | * @param $title \type{\string} the DB key form the title |
502 | 500 | * @param $fragment \type{\string} The link fragment (after the "#") |
503 | | - * @param $interwiki \type{\string} The interwiki prefix |
504 | 501 | * @return \type{\string} the prefixed form of the title |
505 | 502 | */ |
506 | | - public static function makeName( $ns, $title, $fragment = '', $interwiki = '' ) { |
| 503 | + public static function makeName( $ns, $title, $fragment = '' ) { |
507 | 504 | global $wgContLang; |
508 | 505 | |
509 | 506 | $namespace = $wgContLang->getNsText( $ns ); |
510 | 507 | $name = $namespace == '' ? $title : "$namespace:$title"; |
511 | | - if ( strval( $interwiki ) != '' ) { |
512 | | - $name = "$interwiki:$name"; |
513 | | - } |
514 | 508 | if ( strval( $fragment ) != '' ) { |
515 | 509 | $name .= '#' . $fragment; |
516 | 510 | } |