protected $logger;
/** @var array Track original session fields for later modification check */
- protected $sessionFieldCache = array();
+ protected $sessionFieldCache = [];
protected function __construct( SessionManager $manager ) {
$this->setEnableFlags(
return;
}
+ // @codeCoverageIgnoreStart
+ if ( defined( 'MW_NO_SESSION_HANDLER' ) ) {
+ throw new \BadMethodCallException( 'MW_NO_SESSION_HANDLER is defined' );
+ }
+ // @codeCoverageIgnoreEnd
+
self::$instance = new self( $manager );
// Close any auto-started session, before we replace it
if ( self::$instance !== $this ) {
throw new \UnexpectedValueException( __METHOD__ . ': Wrong instance called!' );
}
- $this->sessionFieldCache = array();
+ $this->sessionFieldCache = [];
return true;
}
// invalid. Let's emit a log warning instead of a PHP warning.
$this->logger->warning(
__METHOD__ . ': Session "{session}" cannot be loaded, skipping write.',
- array(
+ [
'session' => $id,
- ) );
+ ] );
return true;
}
// Now merge the data into the Session object.
$changed = false;
- $cache = isset( $this->sessionFieldCache[$id] ) ? $this->sessionFieldCache[$id] : array();
+ $cache = isset( $this->sessionFieldCache[$id] ) ? $this->sessionFieldCache[$id] : [];
foreach ( $data as $key => $value ) {
if ( !array_key_exists( $key, $cache ) ) {
if ( $session->exists( $key ) ) {
\Wikimedia\PhpSessionSerializer::setLogger( new \Psr\Log\NullLogger() );
foreach ( $cache as $key => $value ) {
if ( !array_key_exists( $key, $data ) && $session->exists( $key ) &&
- \Wikimedia\PhpSessionSerializer::encode( array( $key => true ) )
+ \Wikimedia\PhpSessionSerializer::encode( [ $key => true ] )
) {
if ( $cache[$key] === $session->get( $key ) ) {
// Unchanged in Session, delete it