1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace IntegerNet\SessionUnblocker\Plugin; |
5
|
|
|
|
6
|
|
|
use Magento\Framework\Session\Generic as GenericSession; |
7
|
|
|
use Magento\Framework\Session\SessionManagerInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* We are writing this plugin to make sure sessions are all loaded |
11
|
|
|
* Magento\Banner\Controller\Ajax\Load |
12
|
|
|
* |
13
|
|
|
* Right after initiating all the needed Sessions we close the session, |
14
|
|
|
* since we're only reading from the session when requesting banners. |
15
|
|
|
*/ |
16
|
|
|
class BannerAjaxLoadControllerPlugin |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @param GenericSession $genericSession |
20
|
|
|
* @param SessionManagerInterface[] $additionalSessions |
21
|
|
|
* |
22
|
|
|
* Disabling 3 PHPCS rules because: |
23
|
|
|
* 1 - We are well aware that we normally shouldn't call Sessions without |
24
|
|
|
* proxy, but in this case, we actually want the sessions to be |
25
|
|
|
* initiated directly. |
26
|
|
|
* 2 - Also, we don't actually use the Sessions |
27
|
|
|
* 3 - Lastly, we normally should not execute operations in a constructor |
28
|
|
|
* |
29
|
|
|
* phpcs:disable MEQP2.Classes.MutableObjects.MutableObjects |
30
|
|
|
* phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found |
31
|
|
|
* phpcs:disable MEQP2.Classes.ConstructorOperations.CustomOperationsFound |
32
|
|
|
*/ |
33
|
|
|
public function __construct( |
34
|
|
|
GenericSession $genericSession, |
35
|
|
|
array $additionalSessions = [] |
|
|
|
|
36
|
|
|
) { |
37
|
|
|
/** |
38
|
|
|
* This is earliest moment where we can close the session, |
39
|
|
|
* after we initialised all sessions we think will be needed |
40
|
|
|
* |
41
|
|
|
* Should there ever be an additional Session-type that's needed, |
42
|
|
|
* nothing breaks, but the new session-type will open a new session |
43
|
|
|
* and therefore block other requests |
44
|
|
|
*/ |
45
|
|
|
$genericSession->writeClose(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
//phpcs:ignore MEQP2.Classes.PublicNonInterfaceMethods.PublicMethodFound |
49
|
|
|
public function beforeExecute() |
50
|
|
|
{ |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.