File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -40,15 +40,31 @@ public function __construct(
4040 GenericSession $ genericSession ,
4141 array $ additionalSessions = []
4242 ) {
43- /*
43+ /**
4444 * This is earliest moment where we can close the session,
4545 * after we initialised all sessions we think will be needed
4646 *
4747 * Should there ever be an additional Session-type that's needed,
4848 * nothing breaks, but the new session-type will open a new session
4949 * and therefore block other requests
5050 */
51- $ genericSession ->writeClose ();
51+ $ hasMessages = 0 ;
52+ foreach ($ additionalSessions as $ session ) {
53+ if ($ session instanceOf \Magento \Framework \Message \Session){
54+ // @param \Magento\Framework\Message\Collection $messageCollection
55+ foreach ($ session ->getData () as $ messageCollection ){
56+ $ hasMessages += count ($ messageCollection ->getItems ());
57+ }
58+ }
59+ }
60+ /**
61+ * We've checked if there were no messages in the current session
62+ * because the session then needs to stay open to allow the messages
63+ * to be removed after loading them
64+ */
65+ if ($ hasMessages === 0 ) {
66+ $ genericSession ->writeClose ();
67+ }
5268 }
5369
5470 //phpcs:ignore MEQP2.Classes.PublicNonInterfaceMethods.PublicMethodFound
You can’t perform that action at this time.
0 commit comments