Clarified RequestContext doc comment
[lhc/web/wiklou.git] / includes / context / RequestContext.php
index 2a610a3..89a0f3d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Request-dependant objects containers.
+ * Container for request-dependant objects and site configuration
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -140,7 +140,7 @@ class RequestContext implements IContextSource {
                if ( $this->title === null ) {
                        global $wgTitle; # fallback to $wg till we can improve this
                        $this->title = $wgTitle;
-                       wfDebugLog( 'GlobalTitleFail', __METHOD__ . ' called by ' . wfGetAllCallers() . ' with no title set.' );
+                       wfDebugLog( 'GlobalTitleFail', __METHOD__ . ' called by ' . wfGetAllCallers( 5 ) . ' with no title set.' );
                }
 
                return $this->title;
@@ -182,9 +182,8 @@ class RequestContext implements IContextSource {
         * @param WikiPage $p
         */
        public function setWikiPage( WikiPage $p ) {
-               $contextTitle = $this->getTitle();
                $pageTitle = $p->getTitle();
-               if ( !$contextTitle || !$pageTitle->equals( $contextTitle ) ) {
+               if ( !$this->hasTitle() || !$pageTitle->equals( $this->getTitle() ) ) {
                        $this->setTitle( $pageTitle );
                }
                // Defer this to the end since setTitle sets it to null.
@@ -298,8 +297,8 @@ class RequestContext implements IContextSource {
        /**
         * Get the Language object.
         * Initialization of user or request objects can depend on this.
-        *
         * @return Language
+        * @throws Exception
         * @since 1.19
         */
        public function getLanguage() {
@@ -319,7 +318,10 @@ class RequestContext implements IContextSource {
                                $request = $this->getRequest();
                                $user = $this->getUser();
 
-                               $code = $request->getVal( 'uselang', $user->getOption( 'language' ) );
+                               $code = $request->getVal( 'uselang', 'user' );
+                               if ( $code === 'user' ) {
+                                       $code = $user->getOption( 'language' );
+                               }
                                $code = self::sanitizeLangCode( $code );
 
                                Hooks::run( 'UserGetLanguageObject', array( $user, &$code, $this ) );
@@ -359,7 +361,6 @@ class RequestContext implements IContextSource {
         */
        public function getSkin() {
                if ( $this->skin === null ) {
-                       wfProfileIn( __METHOD__ . '-createskin' );
 
                        $skin = null;
                        Hooks::run( 'RequestContextCreateSkin', array( $this, &$skin ) );
@@ -397,7 +398,6 @@ class RequestContext implements IContextSource {
 
                        // After all that set a context on whatever skin got created
                        $this->skin->setContext( $this );
-                       wfProfileOut( __METHOD__ . '-createskin' );
                }
 
                return $this->skin;