Do not vary on session cookies when the session is disabled
authorGergő Tisza <tgr.huwiki@gmail.com>
Wed, 24 Feb 2016 06:45:04 +0000 (22:45 -0800)
committerGergő Tisza <tgr.huwiki@gmail.com>
Thu, 25 Feb 2016 20:51:32 +0000 (12:51 -0800)
MW_NO_SESSION is supposed to be used in a deterministic way
(either always or never for a given endpoint) so there is
no point to split the cache on session cookies when it is
used (except when it's set to 'warn' in which case it is
not really used).

Bug: T127233
Change-Id: If44e0ec2167359e081e1b4cd4d21e62bd357d23e

includes/session/SessionManager.php

index 1aab12a..b1d5d77 100644 (file)
@@ -296,6 +296,9 @@ final class SessionManager implements SessionManagerInterface {
        }
 
        public function getVaryHeaders() {
+               if ( defined( 'MW_NO_SESSION' ) && MW_NO_SESSION !== 'warn' ) {
+                       return [];
+               }
                if ( $this->varyHeaders === null ) {
                        $headers = [];
                        foreach ( $this->getProviders() as $provider ) {
@@ -314,6 +317,9 @@ final class SessionManager implements SessionManagerInterface {
        }
 
        public function getVaryCookies() {
+               if ( defined( 'MW_NO_SESSION' ) && MW_NO_SESSION !== 'warn' ) {
+                       return [];
+               }
                if ( $this->varyCookies === null ) {
                        $cookies = [];
                        foreach ( $this->getProviders() as $provider ) {