Merge "Change 1.26 to 1.27, mostly in doc comments"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 755b165..4f99f34 100644 (file)
@@ -236,7 +236,7 @@ class OutputPage extends ContextSource {
 
        /** @var int Cache stuff. Looks like mEnableClientCache */
        protected $mSquidMaxage = 0;
-       /** @var in Upper limit on mSquidMaxage */
+       /** @var int Upper limit on mSquidMaxage */
        protected $mCdnMaxageLimit = INF;
 
        /**
@@ -1957,7 +1957,7 @@ class OutputPage extends ContextSource {
         * @since 1.27
         */
        public function lowerCdnMaxage( $maxage ) {
-               $this->mCdnMaxageLimit = $this->min( $maxage, $this->mCdnMaxageLimit );
+               $this->mCdnMaxageLimit = min( $maxage, $this->mCdnMaxageLimit );
                $this->setSquidMaxage( $this->mSquidMaxage );
        }
 
@@ -2004,7 +2004,7 @@ class OutputPage extends ContextSource {
        function haveCacheVaryCookies() {
                $request = $this->getRequest();
                foreach ( $this->getCacheVaryCookies() as $cookieName ) {
-                       if ( $request->getCookie( $cookieName, '' ) ) {
+                       if ( $request->getCookie( $cookieName, '', '' ) !== '' ) {
                                wfDebug( __METHOD__ . ": found $cookieName\n" );
                                return true;
                        }
@@ -3312,22 +3312,31 @@ class OutputPage extends ContextSource {
         * @return bool
         */
        public function userCanPreview() {
-               if ( $this->getRequest()->getVal( 'action' ) != 'submit'
-                       || !$this->getRequest()->wasPosted()
-                       || !$this->getUser()->matchEditToken(
-                               $this->getRequest()->getVal( 'wpEditToken' ) )
-               ) {
+               $request = $this->getRequest();
+               if ( $request->getVal( 'action' ) !== 'submit' || !$request->wasPosted() ) {
+                       return false;
+               }
+
+               $user = $this->getUser();
+               if ( !$user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
                        return false;
                }
-               if ( !$this->getTitle()->isJsSubpage() && !$this->getTitle()->isCssSubpage() ) {
+
+               $title = $this->getTitle();
+               if ( !$title->isJsSubpage() && !$title->isCssSubpage() ) {
                        return false;
                }
-               if ( !$this->getTitle()->isSubpageOf( $this->getUser()->getUserPage() ) ) {
+               if ( !$title->isSubpageOf( $user->getUserPage() ) ) {
                        // Don't execute another user's CSS or JS on preview (T85855)
                        return false;
                }
 
-               return !count( $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getUser() ) );
+               $errors = $title->getUserPermissionsErrors( 'edit', $user );
+               if ( count( $errors ) !== 0 ) {
+                       return false;
+               }
+
+               return true;
        }
 
        /**