Preferences.php: avoid "Undefined index" if key 'realname' don't exist in $formdata
[lhc/web/wiklou.git] / includes / AjaxResponse.php
index a395239..ac8a9f0 100644 (file)
@@ -1,6 +1,21 @@
 <?php
 /**
- * Response handler for Ajax requests
+ * Response handler for Ajax requests.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
  * @ingroup Ajax
  * @ingroup Ajax
  */
 class AjaxResponse {
-       /** Number of seconds to get the response cached by a proxy */
+
+       /**
+        * Number of seconds to get the response cached by a proxy
+        * @var int $mCacheDuration
+        */
        private $mCacheDuration;
 
-       /** HTTP header Content-Type */
+       /**
+        * HTTP header Content-Type
+        * @var string $mContentType
+        */
        private $mContentType;
 
-       /** Disables output. Can be set by calling $AjaxResponse->disable() */
+       /**
+        * Disables output. Can be set by calling $AjaxResponse->disable()
+        * @var bool $mDisabled
+        */
        private $mDisabled;
 
-       /** Date for the HTTP header Last-modified */
+       /**
+        * Date for the HTTP header Last-modified
+        * @var string|false $mLastModified
+        */
        private $mLastModified;
 
-       /** HTTP response code */
+       /**
+        * HTTP response code
+        * @var string $mResponseCode
+        */
        private $mResponseCode;
 
-       /** HTTP Vary header */
+       /**
+        * HTTP Vary header
+        * @var string $mVary
+        */
        private $mVary;
 
-       /** Content of our HTTP response */
+       /**
+        * Content of our HTTP response
+        * @var string $mText
+        */
        private $mText;
 
        /**
@@ -52,22 +89,41 @@ class AjaxResponse {
                }
        }
 
+       /**
+        * Set the number of seconds to get the response cached by a proxy
+        * @param $duration int
+        */
        function setCacheDuration( $duration ) {
                $this->mCacheDuration = $duration;
        }
 
+       /**
+        * Set the HTTP Vary header
+        * @param $vary string
+        */
        function setVary( $vary ) {
                $this->mVary = $vary;
        }
 
+       /**
+        * Set the HTTP response code
+        * @param $code string
+        */
        function setResponseCode( $code ) {
                $this->mResponseCode = $code;
        }
 
+       /**
+        * Set the HTTP header Content-Type
+        * @param $type string
+        */
        function setContentType( $type ) {
                $this->mContentType = $type;
        }
 
+       /**
+        * Disable output.
+        */
        function disable() {
                $this->mDisabled = true;
        }
@@ -116,7 +172,7 @@ class AjaxResponse {
                        # tell the client to use a cached copy, without a way to purge it.
 
                        if ( $wgUseSquid ) {
-                               # Expect explicite purge of the proxy cache, but require end user agents
+                               # Expect explicit purge of the proxy cache, but require end user agents
                                # to revalidate against the proxy on each visit.
                                # Surrogate-Control controls our Squid, Cache-Control downstream caches
 
@@ -148,13 +204,13 @@ class AjaxResponse {
 
        /**
         * checkLastModified tells the client to use the client-cached response if
-        * possible. If sucessful, the AjaxResponse is disabled so that
+        * possible. If successful, the AjaxResponse is disabled so that
         * any future call to AjaxResponse::printText() have no effect.
         *
         * @param $timestamp string
         * @return bool Returns true if the response code was set to 304 Not Modified.
         */
-       function checkLastModified ( $timestamp ) {
+       function checkLastModified( $timestamp ) {
                global $wgCachePages, $wgCacheEpoch, $wgUser;
                $fname = 'AjaxResponse::checkLastModified';
 
@@ -164,12 +220,7 @@ class AjaxResponse {
                }
 
                if ( !$wgCachePages ) {
-                       wfDebug( "$fname: CACHE DISABLED\n", false );
-                       return false;
-               }
-
-               if ( $wgUser->getOption( 'nocache' ) ) {
-                       wfDebug( "$fname: USER DISABLED CACHE\n", false );
+                       wfDebug( "$fname: CACHE DISABLED\n", 'log' );
                        return false;
                }
 
@@ -183,8 +234,8 @@ class AjaxResponse {
                        $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
                        $modsinceTime = strtotime( $modsince );
                        $ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 );
-                       wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", false );
-                       wfDebug( "$fname: --  we might send Last-Modified : $lastmod\n", false );
+                       wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", 'log' );
+                       wfDebug( "$fname: --  we might send Last-Modified : $lastmod\n", 'log' );
 
                        if ( ( $ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
                                ini_set( 'zlib.output_compression', 0 );
@@ -192,23 +243,23 @@ class AjaxResponse {
                                $this->disable();
                                $this->mLastModified = $lastmod;
 
-                               wfDebug( "$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", false );
+                               wfDebug( "$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", 'log' );
 
                                return true;
                        } else {
-                               wfDebug( "$fname: READY  client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", false );
+                               wfDebug( "$fname: READY  client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", 'log' );
                                $this->mLastModified = $lastmod;
                        }
                } else {
-                       wfDebug( "$fname: client did not send If-Modified-Since header\n", false );
+                       wfDebug( "$fname: client did not send If-Modified-Since header\n", 'log' );
                        $this->mLastModified = $lastmod;
                }
                return false;
        }
 
        /**
-        * @param $mckey
-        * @param $touched
+        * @param $mckey string
+        * @param $touched int
         * @return bool
         */
        function loadFromMemcached( $mckey, $touched ) {
@@ -235,7 +286,7 @@ class AjaxResponse {
        }
 
        /**
-        * @param $mckey
+        * @param $mckey string
         * @param $expiry int
         * @return bool
         */