Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/284480

Change subject: SessionManager: Ignore Session object destruction during global 
shutdown
......................................................................

SessionManager: Ignore Session object destruction during global shutdown

We already save all open SessionBackends when shutdown handlers are run,
which *should* make the Session object destructors that run during
global shutdown not have anything to save. But it can get fooled if the
Session data contains other objects that have already gotten destroyed
during the global shutdown, leading to spurious warnings and errors as
it tries to access partically-destroyed objects.

The solution is to set a flag when we do the shutdown handlers and just
ignore the last gasps from Session::__destroy() that might come after.

Change-Id: Ic3eb0bac2d29a30488c84b6525ad796a7f1c9ce9
---
M includes/session/SessionBackend.php
M includes/session/SessionManager.php
2 files changed, 13 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/80/284480/1

diff --git a/includes/session/SessionBackend.php 
b/includes/session/SessionBackend.php
index 2626aa8..264e1ae 100644
--- a/includes/session/SessionBackend.php
+++ b/includes/session/SessionBackend.php
@@ -94,6 +94,8 @@
        private $usePhpSessionHandling = true;
        private $checkPHPSessionRecursionGuard = false;
 
+       private $shutdown = false;
+
        /**
         * @param SessionId $id Session ID object
         * @param SessionInfo $info Session info to populate from
@@ -181,13 +183,22 @@
         */
        public function deregisterSession( $index ) {
                unset( $this->requests[$index] );
-               if ( !count( $this->requests ) ) {
+               if ( !$this->shutdown && !count( $this->requests ) ) {
                        $this->save( true );
                        
$this->provider->getManager()->deregisterSessionBackend( $this );
                }
        }
 
        /**
+        * Shut down a session
+        * @private For use by \MediaWiki\Session\SessionManager::shutdown() 
only
+        */
+       public function shutdown() {
+               $this->save( true );
+               $this->shutdown = true;
+       }
+
+       /**
         * Returns the session ID.
         * @return string
         */
diff --git a/includes/session/SessionManager.php 
b/includes/session/SessionManager.php
index 29cd69a..a364045 100644
--- a/includes/session/SessionManager.php
+++ b/includes/session/SessionManager.php
@@ -626,7 +626,7 @@
                        }
                        // @codeCoverageIgnoreEnd
                        foreach ( $this->allSessionBackends as $backend ) {
-                               $backend->save( true );
+                               $backend->shutdown();
                        }
                }
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/284480
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3eb0bac2d29a30488c84b6525ad796a7f1c9ce9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to