PHPSessionHandler: Suppress warnings in initialize()
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 13 Jun 2018 13:51:57 +0000 (09:51 -0400)
committerReedy <reedy@wikimedia.org>
Mon, 30 Jul 2018 00:37:55 +0000 (01:37 +0100)
PHP 7.2 has gotten strict about calling various session-related methods
after headers were sent. Even in CLI mode where there are no headers to
send in the first place. Silence these warnings.

Bug: T197030
Change-Id: Idaabf1320c56e0d6c26387f03af05f32e1496a1c
(cherry picked from commit 701854b3ebc3c2b06067823395a7d95e8984cfda)

RELEASE-NOTES-1.31
includes/session/PHPSessionHandler.php

index a67aca0..4841f77 100644 (file)
@@ -14,8 +14,7 @@ This is a security and maintenance release of the MediaWiki 1.31 branch.
 * (T198037) GitInfo: Don't try shelling out if it's disabled.
 * (T151415) Log email changes.
 * (T197206) Fix performance regression when multiple DB used without caching.
 * (T198037) GitInfo: Don't try shelling out if it's disabled.
 * (T151415) Log email changes.
 * (T197206) Fix performance regression when multiple DB used without caching.
-
-== MediaWiki 1.31 ==
+* (T197030) PHPSessionHandler: Suppress headers warnings in initialize().
 
 === Changes since MediaWiki 1.31.0-rc.2 ===
 * (T195783) Initialize PSR-4 namespaces at same stage as normal autoloader.
 
 === Changes since MediaWiki 1.31.0-rc.2 ===
 * (T195783) Initialize PSR-4 namespaces at same stage as normal autoloader.
index b76f0ff..e1415df 100644 (file)
@@ -122,22 +122,28 @@ class PHPSessionHandler implements \SessionHandlerInterface {
                // Close any auto-started session, before we replace it
                session_write_close();
 
                // Close any auto-started session, before we replace it
                session_write_close();
 
-               // Tell PHP not to mess with cookies itself
-               ini_set( 'session.use_cookies', 0 );
-               ini_set( 'session.use_trans_sid', 0 );
-
-               // T124510: Disable automatic PHP session related cache headers.
-               // MediaWiki adds it's own headers and the default PHP behavior may
-               // set headers such as 'Pragma: no-cache' that cause problems with
-               // some user agents.
-               session_cache_limiter( '' );
-
-               // Also set a sane serialization handler
-               \Wikimedia\PhpSessionSerializer::setSerializeHandler();
-
-               // Register this as the save handler, and register an appropriate
-               // shutdown function.
-               session_set_save_handler( self::$instance, true );
+               try {
+                       \Wikimedia\suppressWarnings();
+
+                       // Tell PHP not to mess with cookies itself
+                       ini_set( 'session.use_cookies', 0 );
+                       ini_set( 'session.use_trans_sid', 0 );
+
+                       // T124510: Disable automatic PHP session related cache headers.
+                       // MediaWiki adds it's own headers and the default PHP behavior may
+                       // set headers such as 'Pragma: no-cache' that cause problems with
+                       // some user agents.
+                       session_cache_limiter( '' );
+
+                       // Also set a sane serialization handler
+                       \Wikimedia\PhpSessionSerializer::setSerializeHandler();
+
+                       // Register this as the save handler, and register an appropriate
+                       // shutdown function.
+                       session_set_save_handler( self::$instance, true );
+               } finally {
+                       \Wikimedia\restoreWarnings();
+               }
        }
 
        /**
        }
 
        /**