* (bug 32786) Fix backwards compatibility for extensions using 1.17's Database::newFr...
[lhc/web/wiklou.git] / includes / OutputPage.php
index e6b18a9..feae2c1 100644 (file)
@@ -222,6 +222,14 @@ class OutputPage extends ContextSource {
                'Cookie' => null
        );
 
+       /**
+        * If the current page was reached through a redirect, $mRedirectedFrom contains the Title
+        * of the redirect.
+        *
+        * @var Title
+        */
+       private $mRedirectedFrom = null;
+
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
@@ -776,6 +784,15 @@ class OutputPage extends ContextSource {
                return $this->mHTMLtitle;
        }
 
+       /**
+        * Set $mRedirectedFrom, the Title of the page which redirected us to the current page.
+        *
+        * param @t Title
+        */
+       public function setRedirectedFrom( $t ) {
+               $this->mRedirectedFrom = $t;
+       }
+
        /**
         * "Page title" means the contents of \<h1\>. It is stored as a valid HTML fragment.
         * This function allows good tags like \<sup\> in the \<h1\> tag, but not bad tags like \<script\>.
@@ -2030,9 +2047,9 @@ class OutputPage extends ContextSource {
                ) {
                        $displayReturnto = null;
 
-                       # Due to bug 32276, if a user does not have read permissions, 
-                       # $this->getTitle() will just give Special:Badtitle, which is 
-                       # not especially useful as a returnto parameter. Use the title 
+                       # Due to bug 32276, if a user does not have read permissions,
+                       # $this->getTitle() will just give Special:Badtitle, which is
+                       # not especially useful as a returnto parameter. Use the title
                        # from the request instead, if there was one.
                        $request = $this->getRequest();
                        $returnto = Title::newFromURL( $request->getVal( 'title', '' ) );
@@ -2721,6 +2738,7 @@ $templates
         * - in other words, page-independent/site-wide variables (without state).
         * You will only be adding bloat to the html page and causing page caches to
         * have to be purged on configuration changes.
+        * @return array
         */
        protected function getJSVars() {
                global $wgUseAjax, $wgEnableMWSuggest;
@@ -2780,6 +2798,9 @@ $templates
                if ( $title->isMainPage() ) {
                        $vars['wgIsMainPage'] = true;
                }
+               if ( $this->mRedirectedFrom ) {
+                       $vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBKey();
+               }
 
                // Allow extensions to add their custom variables to the mw.config map.
                // Use the 'ResourceLoaderGetConfigVars' hook if the variable is not