Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -205,36 +205,39 @@ |
206 | 206 | * @return mixed false, Title object of local target, or string with URL |
207 | 207 | */ |
208 | 208 | public function getRedirectURL( $rt ) { |
209 | | - if ( $rt ) { |
210 | | - if ( $rt->getInterwiki() != '' ) { |
211 | | - if ( $rt->isLocal() ) { |
212 | | - // Offsite wikis need an HTTP redirect. |
213 | | - // |
214 | | - // This can be hard to reverse and may produce loops, |
215 | | - // so they may be disabled in the site configuration. |
216 | | - $source = $this->mTitle->getFullURL( 'redirect=no' ); |
217 | | - return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ); |
218 | | - } |
| 209 | + if ( !$rt ) { |
| 210 | + return false; |
| 211 | + } |
| 212 | + |
| 213 | + if ( $rt->isExternal() ) { |
| 214 | + if ( $rt->isLocal() ) { |
| 215 | + // Offsite wikis need an HTTP redirect. |
| 216 | + // |
| 217 | + // This can be hard to reverse and may produce loops, |
| 218 | + // so they may be disabled in the site configuration. |
| 219 | + $source = $this->mTitle->getFullURL( 'redirect=no' ); |
| 220 | + return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ); |
219 | 221 | } else { |
220 | | - if ( $rt->isSpecialPage() ) { |
221 | | - // Gotta handle redirects to special pages differently: |
222 | | - // Fill the HTTP response "Location" header and ignore |
223 | | - // the rest of the page we're on. |
224 | | - // |
225 | | - // This can be hard to reverse, so they may be disabled. |
226 | | - if ( $rt->isSpecial( 'Userlogout' ) ) { |
227 | | - // rolleyes |
228 | | - } else { |
229 | | - return $rt->getFullURL(); |
230 | | - } |
231 | | - } |
| 222 | + // External pages pages without "local" bit set are not valid |
| 223 | + // redirect targets |
| 224 | + return false; |
| 225 | + } |
| 226 | + } |
232 | 227 | |
233 | | - return $rt; |
| 228 | + if ( $rt->isSpecialPage() ) { |
| 229 | + // Gotta handle redirects to special pages differently: |
| 230 | + // Fill the HTTP response "Location" header and ignore |
| 231 | + // the rest of the page we're on. |
| 232 | + // |
| 233 | + // Some pages are not valid targets |
| 234 | + if ( $rt->isValidRedirectTarget() ) { |
| 235 | + return $rt->getFullURL(); |
| 236 | + } else { |
| 237 | + return false; |
234 | 238 | } |
235 | 239 | } |
236 | 240 | |
237 | | - // No or invalid redirect |
238 | | - return false; |
| 241 | + return $rt; |
239 | 242 | } |
240 | 243 | |
241 | 244 | /** |