Merge "Language: s/error_log/wfWarn/"
[lhc/web/wiklou.git] / includes / context / RequestContext.php
index 00733d8..ede10fe 100644 (file)
@@ -123,10 +123,10 @@ class RequestContext implements IContextSource {
        /**
         * Set the Title object
         *
-        * @param Title $t
+        * @param Title $title
         */
-       public function setTitle( Title $t ) {
-               $this->title = $t;
+       public function setTitle( Title $title ) {
+               $this->title = $title;
                // Erase the WikiPage so a new one with the new title gets created.
                $this->wikipage = null;
        }
@@ -297,7 +297,7 @@ class RequestContext implements IContextSource {
                        $e = new Exception;
                        wfDebugLog( 'recursion-guard', "Recursion detected:\n" . $e->getTraceAsString() );
 
-                       $code = $this->getConfig()->get( 'LanguageCode' ) ? : 'en';
+                       $code = $this->getConfig()->get( 'LanguageCode' ) ?: 'en';
                        $this->lang = Language::factory( $code );
                } elseif ( $this->lang === null ) {
                        $this->recursion = true;
@@ -421,6 +421,21 @@ class RequestContext implements IContextSource {
                return self::$instance;
        }
 
+       /**
+        * Get the RequestContext object associated with the main request
+        * and gives a warning to the log, to find places, where a context maybe is missing.
+        *
+        * @param string $func
+        * @return RequestContext
+        * @since 1.24
+        */
+       public static function getMainAndWarn( $func = __METHOD__ ) {
+               wfDebug( $func . ' called without context. ' .
+                       "Using RequestContext::getMain() for sanity\n" );
+
+               return self::getMain();
+       }
+
        /**
         * Resets singleton returned by getMain(). Should be called only from unit tests.
         */