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(
40
40
GenericSession $ genericSession ,
41
41
array $ additionalSessions = []
42
42
) {
43
- /*
43
+ /**
44
44
* This is earliest moment where we can close the session,
45
45
* after we initialised all sessions we think will be needed
46
46
*
47
47
* Should there ever be an additional Session-type that's needed,
48
48
* nothing breaks, but the new session-type will open a new session
49
49
* and therefore block other requests
50
50
*/
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
+ }
52
68
}
53
69
54
70
//phpcs:ignore MEQP2.Classes.PublicNonInterfaceMethods.PublicMethodFound
You can’t perform that action at this time.
0 commit comments