r104668 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104667‎ | r104668 | r104669 >
Date:12:43, 30 November 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 32230) Expose wgRedirectedFrom (title of the page we were redirected from, if any) in JavaScript. Patch by MrBlueSky
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -823,6 +823,9 @@
824824 'href' => $this->getTitle()->getLocalURL() )
825825 );
826826
 827+ // Tell $wgOut the user arrived at this article through a redirect
 828+ $wgOut->setRedirectedFrom( $this->mRedirectedFrom );
 829+
827830 return true;
828831 }
829832 } elseif ( $rdfrom ) {
Index: trunk/phase3/includes/OutputPage.php
@@ -223,6 +223,14 @@
224224 );
225225
226226 /**
 227+ * If the current page was reached through a redirect, $mRedirectedFrom contains the Title
 228+ * of the redirect.
 229+ *
 230+ * @var Title
 231+ */
 232+ private $mRedirectedFrom = null;
 233+
 234+ /**
227235 * Constructor for OutputPage. This should not be called directly.
228236 * Instead a new RequestContext should be created and it will implicitly create
229237 * a OutputPage tied to that context.
@@ -777,6 +785,15 @@
778786 }
779787
780788 /**
 789+ * Set $mRedirectedFrom, the Title of the page which redirected us to the current page.
 790+ *
 791+ * param @t Title
 792+ */
 793+ public function setRedirectedFrom( $t ) {
 794+ $this->mRedirectedFrom = $t;
 795+ }
 796+
 797+ /**
781798 * "Page title" means the contents of \<h1\>. It is stored as a valid HTML fragment.
782799 * This function allows good tags like \<sup\> in the \<h1\> tag, but not bad tags like \<script\>.
783800 * This function automatically sets \<title\> to the same content as \<h1\> but with all tags removed.
@@ -2781,6 +2798,9 @@
27822799 if ( $title->isMainPage() ) {
27832800 $vars['wgIsMainPage'] = true;
27842801 }
 2802+ if ( $this->mRedirectedFrom ) {
 2803+ $vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBKey();
 2804+ }
27852805
27862806 // Allow extensions to add their custom variables to the mw.config map.
27872807 // Use the 'ResourceLoaderGetConfigVars' hook if the variable is not

Sign-offs

UserFlagDate
😂inspected14:43, 1 December 2011
Brion VIBBERinspected23:05, 1 December 2011
Brion VIBBERtested23:05, 1 December 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r104686RELEASE-NOTES for r104668, r104671, r104684catrope14:56, 30 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   08:22, 2 December 2011

Why not add type hint?

public function setRedirectedFrom( Title $t = null ) {

Status & tagging log