r37014 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37013‎ | r37014 | r37015 >
Date:00:04, 4 July 2008
Author:brion
Status:old
Tags:
Comment:
Revert r37006 -- causes fatal errors:
PHP Fatal error: Using $this when not in object context in Article.php on line 135
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -698,12 +698,6 @@
699699 &$file: File object
700700 &$displayFile: displayed File object
701701
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 -
708702 'InitPreferencesForm': called at the end of PreferencesForm's constructor
709703 $form: the PreferencesForm
710704 $request: the web request to initialized from
Index: trunk/phase3/includes/Article.php
@@ -111,18 +111,10 @@
112112 *
113113 * @return mixed false, Title of in-wiki target, or string with URL
114114 */
115 - public function followRedirect() {
 115+ function followRedirect() {
116116 $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 ) {
126117 $rt = Title::newFromRedirect( $text );
 118+
127119 # process if title object is valid and not special:userlogout
128120 if( $rt ) {
129121 if( $rt->getInterwiki() != '' ) {
@@ -152,6 +144,7 @@
153145 return $rt;
154146 }
155147 }
 148+
156149 // No or invalid redirect
157150 return false;
158151 }
Index: trunk/phase3/includes/Wiki.php
@@ -43,7 +43,7 @@
4444 * Initialization of ... everything
4545 * Performs the request too
4646 *
47 - * @param $title Title ($wgTitle)
 47+ * @param $title Title
4848 * @param $article Article
4949 * @param $output OutputPage
5050 * @param $user User
@@ -264,7 +264,7 @@
265265 * Initialize the object to be known as $wgArticle for "standard" actions
266266 * Create an Article object for the page, following redirects if needed.
267267 *
268 - * @param $title Title ($wgTitle)
 268+ * @param $title Title
269269 * @param $request WebRequest
270270 * @return mixed an Article, or a string to redirect to another URL
271271 */
@@ -280,22 +280,18 @@
281281 // Check for redirects ...
282282 $file = $title->getNamespace() == NS_IMAGE ? $article->getFile() : null;
283283 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
285285 $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
288289
289 - # Give extensions a change to ignore/handle redirects as needed
290 - $ignoreRedirect = $target = false;
291 - wfRunHooks( 'InitializeArticleMaybeRedirect', array( &$title, &$request, &$ignoreRedirect, &$target ) );
292 -
293290 $dbr = wfGetDB( DB_SLAVE );
294291 $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) );
295292
296293 // 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();
300296 if( is_string( $target ) ) {
301297 if( !$this->getVal( 'DisableHardRedirects' ) ) {
302298 // we'll need to redirect
@@ -307,7 +303,9 @@
308304 // Rewrite environment to redirected article
309305 $rarticle = self::articleFromTitle( $target );
310306 $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() ) ) {
312310 $rarticle->setRedirectedFrom( $title );
313311 $article = $rarticle;
314312 $title = $target;
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -316,14 +316,12 @@
317317 # Visibility - experimental
318318 $wgHooks['userCan'][] = 'FlaggedRevs::userCanView';
319319
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
325321 $wgHooks['SkinTemplateTabs'][] = 'FlaggedRevs::setActionTabs';
326322 # Change last-modified footer
327323 $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'FlaggedRevs::setLastModified';
 324+# Override current revision, add patrol links, set cache...
 325+$wgHooks['ArticleViewHeader'][] = 'FlaggedRevs::onArticleViewHeader';
328326 # Add page notice
329327 $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'FlaggedRevs::setPermaLink';
330328 # Add tags do edit view
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -2010,26 +2010,6 @@
20112011 return true;
20122012 }
20132013
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 -
20342014 static function setPermaLink( $skin, &$navUrls, &$revId, &$id ) {
20352015 $fa = FlaggedArticle::getGlobalInstance();
20362016 if ( $fa ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r37006Make redirects work properly with flagging (bug 14714)aaron20:37, 3 July 2008

Status & tagging log