Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -698,12 +698,6 @@ |
699 | 699 | &$file: File object |
700 | 700 | &$displayFile: displayed File object |
701 | 701 | |
702 | | -'InitializeArticleMaybeRedirect': MediaWiki check to see if title is a redirect |
703 | | -$title: Title object ($wgTitle) |
704 | | -$request: WebRequest |
705 | | -$ignoreRedirect: boolean to skip redirect check |
706 | | -$target: Title/string of redirect target |
707 | | - |
708 | 702 | 'InitPreferencesForm': called at the end of PreferencesForm's constructor |
709 | 703 | $form: the PreferencesForm |
710 | 704 | $request: the web request to initialized from |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -111,18 +111,10 @@ |
112 | 112 | * |
113 | 113 | * @return mixed false, Title of in-wiki target, or string with URL |
114 | 114 | */ |
115 | | - public function followRedirect() { |
| 115 | + function followRedirect() { |
116 | 116 | $text = $this->getContent(); |
117 | | - return self::followRedirectText( $text ); |
118 | | - } |
119 | | - |
120 | | - /** |
121 | | - * Get the Title object this text redirects to |
122 | | - * |
123 | | - * @return mixed false, Title of in-wiki target, or string with URL |
124 | | - */ |
125 | | - public static function followRedirectText( $text ) { |
126 | 117 | $rt = Title::newFromRedirect( $text ); |
| 118 | + |
127 | 119 | # process if title object is valid and not special:userlogout |
128 | 120 | if( $rt ) { |
129 | 121 | if( $rt->getInterwiki() != '' ) { |
— | — | @@ -152,6 +144,7 @@ |
153 | 145 | return $rt; |
154 | 146 | } |
155 | 147 | } |
| 148 | + |
156 | 149 | // No or invalid redirect |
157 | 150 | return false; |
158 | 151 | } |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | * Initialization of ... everything |
45 | 45 | * Performs the request too |
46 | 46 | * |
47 | | - * @param $title Title ($wgTitle) |
| 47 | + * @param $title Title |
48 | 48 | * @param $article Article |
49 | 49 | * @param $output OutputPage |
50 | 50 | * @param $user User |
— | — | @@ -264,7 +264,7 @@ |
265 | 265 | * Initialize the object to be known as $wgArticle for "standard" actions |
266 | 266 | * Create an Article object for the page, following redirects if needed. |
267 | 267 | * |
268 | | - * @param $title Title ($wgTitle) |
| 268 | + * @param $title Title |
269 | 269 | * @param $request WebRequest |
270 | 270 | * @return mixed an Article, or a string to redirect to another URL |
271 | 271 | */ |
— | — | @@ -280,22 +280,18 @@ |
281 | 281 | // Check for redirects ... |
282 | 282 | $file = $title->getNamespace() == NS_IMAGE ? $article->getFile() : null; |
283 | 283 | if( ( $action == 'view' || $action == 'render' ) // ... for actions that show content |
284 | | - && !$request->getVal( 'oldid' ) && // ... and are not old revisions |
| 284 | + && !$request->getVal( 'oldid' ) && // ... and are not old revisions |
285 | 285 | $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to |
286 | | - // ... and the article is not a non-redirect image page with associated file |
287 | | - !( is_object( $file ) && $file->exists() && !$file->getRedirected() ) ) { |
| 286 | + // ... and the article is not an image page with associated file |
| 287 | + !( is_object( $file ) && $file->exists() && |
| 288 | + !$file->getRedirected() ) ) { // ... unless it is really an image redirect |
288 | 289 | |
289 | | - # Give extensions a change to ignore/handle redirects as needed |
290 | | - $ignoreRedirect = $target = false; |
291 | | - wfRunHooks( 'InitializeArticleMaybeRedirect', array( &$title, &$request, &$ignoreRedirect, &$target ) ); |
292 | | - |
293 | 290 | $dbr = wfGetDB( DB_SLAVE ); |
294 | 291 | $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) ); |
295 | 292 | |
296 | 293 | // Follow redirects only for... redirects |
297 | | - if( !$ignoreRedirect && $article->isRedirect() ) { |
298 | | - # Is the target already set by an extension? |
299 | | - $target = $target ? $target : $article->followRedirect(); |
| 294 | + if( $article->isRedirect() ) { |
| 295 | + $target = $article->followRedirect(); |
300 | 296 | if( is_string( $target ) ) { |
301 | 297 | if( !$this->getVal( 'DisableHardRedirects' ) ) { |
302 | 298 | // we'll need to redirect |
— | — | @@ -307,7 +303,9 @@ |
308 | 304 | // Rewrite environment to redirected article |
309 | 305 | $rarticle = self::articleFromTitle( $target ); |
310 | 306 | $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) ); |
311 | | - if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) { |
| 307 | + if ( $rarticle->getTitle()->exists() || |
| 308 | + ( is_object( $file ) && |
| 309 | + !$file->isLocal() ) ) { |
312 | 310 | $rarticle->setRedirectedFrom( $title ); |
313 | 311 | $article = $rarticle; |
314 | 312 | $title = $target; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -316,14 +316,12 @@ |
317 | 317 | # Visibility - experimental |
318 | 318 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanView'; |
319 | 319 | |
320 | | -# Override current revision, add patrol links, set cache... |
321 | | -$wgHooks['ArticleViewHeader'][] = 'FlaggedRevs::onArticleViewHeader'; |
322 | | -# Override redirect behavoir... |
323 | | -$wgHooks['InitializeArticleMaybeRedirect'][] = 'FlaggedRevs::overrideRedirect'; |
324 | | -# Sets tabs and permalink |
| 320 | +# Main hooks, overrides pages content, adds tags, sets tabs and permalink |
325 | 321 | $wgHooks['SkinTemplateTabs'][] = 'FlaggedRevs::setActionTabs'; |
326 | 322 | # Change last-modified footer |
327 | 323 | $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'FlaggedRevs::setLastModified'; |
| 324 | +# Override current revision, add patrol links, set cache... |
| 325 | +$wgHooks['ArticleViewHeader'][] = 'FlaggedRevs::onArticleViewHeader'; |
328 | 326 | # Add page notice |
329 | 327 | $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'FlaggedRevs::setPermaLink'; |
330 | 328 | # Add tags do edit view |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -2010,26 +2010,6 @@ |
2011 | 2011 | return true; |
2012 | 2012 | } |
2013 | 2013 | |
2014 | | - static function overrideRedirect( &$title, $request, &$ignoreRedirect, &$target ) { |
2015 | | - if( $request->getVal( 'stableid' ) ) { |
2016 | | - $ignoreRedirect = true; |
2017 | | - } else { |
2018 | | - # Get an instance on the title ($wgTitle) and save to process cache |
2019 | | - $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
2020 | | - $srev = $flaggedArticle->getStableRev( true ); |
2021 | | - if( $srev ) { |
2022 | | - $text = $srev->getRevText(); |
2023 | | - $redirect = Article::followRedirectText( $text ); |
2024 | | - if( $redirect ) { |
2025 | | - $target = $redirect; |
2026 | | - } else { |
2027 | | - $ignoreRedirect = true; |
2028 | | - } |
2029 | | - } |
2030 | | - } |
2031 | | - return true; |
2032 | | - } |
2033 | | - |
2034 | 2014 | static function setPermaLink( $skin, &$navUrls, &$revId, &$id ) { |
2035 | 2015 | $fa = FlaggedArticle::getGlobalInstance(); |
2036 | 2016 | if ( $fa ) { |