Skip to content

Commit 696cda8

Browse files
committed
ACPT-1052: Some Luma Storefront Scenarios Are Broken
1 parent d5d95c1 commit 696cda8

File tree

5 files changed

+77
-9
lines changed

5 files changed

+77
-9
lines changed

lib/internal/Magento/Framework/App/Request/Http.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
namespace Magento\Framework\App\Request;
99

10+
use Laminas\Stdlib\Parameters;
1011
use Magento\Framework\App\HttpRequestInterface;
1112
use Magento\Framework\App\RequestContentInterface;
1213
use Magento\Framework\App\RequestSafetyInterface;
1314
use Magento\Framework\App\Route\ConfigInterface;
1415
use Magento\Framework\HTTP\PhpEnvironment\Request;
16+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1517
use Magento\Framework\ObjectManagerInterface;
1618
use Magento\Framework\Stdlib\Cookie\CookieReaderInterface;
1719
use Magento\Framework\Stdlib\StringUtils;
@@ -22,7 +24,7 @@
2224
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2325
* @api
2426
*/
25-
class Http extends Request implements RequestContentInterface, RequestSafetyInterface, HttpRequestInterface
27+
class Http extends Request implements RequestContentInterface, RequestSafetyInterface, HttpRequestInterface, ResetAfterRequestInterface
2628
{
2729
/**#@+
2830
* HTTP Ports
@@ -423,4 +425,34 @@ public function isSafeMethod()
423425
}
424426
return $this->isSafeMethod;
425427
}
428+
429+
/**
430+
* @inheritDoc
431+
*/
432+
public function _resetState(): void
433+
{
434+
$this->setEnv(new Parameters($_ENV));
435+
$this->serverParams = new Parameters($_SERVER);
436+
$this->setQuery(new Parameters([]));
437+
$this->setPost(new Parameters([]));
438+
$this->setFiles(new Parameters([]));
439+
$this->module = null;
440+
$this->controller= null;
441+
$this->action = null;
442+
$this->pathInfo = '';
443+
$this->requestString = '';
444+
$this->params = [];
445+
$this->aliases = [];
446+
$this->dispatched = false;
447+
$this->forwarded = null;
448+
$this->baseUrl = null;
449+
$this->basePath = null;
450+
$this->requestUri = null;
451+
$this->method = 'GET';
452+
$this->allowCustomMethods = true;
453+
$this->uri = null;
454+
$this->headers = null;
455+
$this->metadata = [];
456+
$this->content = '';
457+
}
426458
}

lib/internal/Magento/Framework/GraphQl/Query/QueryComplexityLimiter.php

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use GraphQL\Validator\Rules\QueryDepth;
1818
use GraphQL\Validator\Rules\QueryComplexity;
1919
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
20+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
2021

2122
/**
2223
* QueryComplexityLimiter
@@ -27,7 +28,7 @@
2728
*
2829
* https://github.com/webonyx/graphql-php/blob/master/docs/security.md#query-complexity-analysis
2930
*/
30-
class QueryComplexityLimiter
31+
class QueryComplexityLimiter implements ResetAfterRequestInterface
3132
{
3233
/**
3334
* @var int
@@ -44,6 +45,8 @@ class QueryComplexityLimiter
4445
*/
4546
private $introspectionConfig;
4647

48+
49+
private $rules = [];
4750
/**
4851
* @param int $queryDepth
4952
* @param int $queryComplexity
@@ -59,6 +62,16 @@ public function __construct(
5962
$this->introspectionConfig = $introspectionConfig;
6063
}
6164

65+
66+
private function getRules()
67+
{
68+
if (empty($this->rules)) {
69+
$this->rules[] = new QueryComplexity($this->queryComplexity);
70+
$this->rules[] = new DisableIntrospection((int) $this->introspectionConfig->isIntrospectionDisabled());
71+
$this->rules[] = new QueryDepth($this->queryDepth);
72+
}
73+
return $this->rules;
74+
}
6275
/**
6376
* Sets limits for query complexity
6477
*
@@ -67,11 +80,9 @@ public function __construct(
6780
*/
6881
public function execute(): void
6982
{
70-
DocumentValidator::addRule(new QueryComplexity($this->queryComplexity));
71-
DocumentValidator::addRule(
72-
new DisableIntrospection((int) $this->introspectionConfig->isIntrospectionDisabled())
73-
);
74-
DocumentValidator::addRule(new QueryDepth($this->queryDepth));
83+
foreach ($this->getRules() as $rule) {
84+
DocumentValidator::addRule($rule);
85+
}
7586
}
7687

7788
/**
@@ -108,4 +119,16 @@ public function validateFieldCount(string $query): void
108119
}
109120
}
110121
}
122+
123+
/**
124+
* @inheritDoc
125+
*/
126+
public function _resetState(): void
127+
{
128+
foreach ($this->getRules() as $rule) {
129+
DocumentValidator::removeRule($rule);
130+
unset($rule);
131+
};
132+
$this->rules = [];
133+
}
111134
}

lib/internal/Magento/Framework/Locale/Resolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,6 @@ public function revert()
181181
public function _resetState(): void
182182
{
183183
$this->locale = null;
184+
$this->emulatedLocales = [];
184185
}
185186
}

lib/internal/Magento/Framework/Url.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Framework;
88

99
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1011
use Magento\Framework\Serialize\Serializer\Json;
1112
use Magento\Framework\Url\HostChecker;
1213

@@ -64,7 +65,7 @@
6465
* @SuppressWarnings(PHPMD.TooManyFields)
6566
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
6667
*/
67-
class Url extends \Magento\Framework\DataObject implements \Magento\Framework\UrlInterface
68+
class Url extends \Magento\Framework\DataObject implements \Magento\Framework\UrlInterface, ResetAfterRequestInterface
6869
{
6970
/**
7071
* Configuration data cache
@@ -1192,6 +1193,7 @@ private function getEscaper()
11921193
public function _resetState(): void
11931194
{
11941195
$this->_data = [];
1196+
$this->cacheUrl = [];
11951197
self::$_configDataCache = [];
11961198
}
11971199
}

lib/internal/Magento/Framework/View/Asset/Repository.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Framework\View\Asset;
88

9+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
910
use Magento\Framework\UrlInterface;
1011
use Magento\Framework\App\Filesystem\DirectoryList;
1112
use Magento\Framework\App\ObjectManager;
@@ -19,7 +20,7 @@
1920
* @api
2021
* @since 100.0.2
2122
*/
22-
class Repository
23+
class Repository implements ResetAfterRequestInterface
2324
{
2425
/**
2526
* Scope separator for module notation of file ID
@@ -467,4 +468,13 @@ private function getRepositoryFilesMap($fileId, array $params)
467468
$repositoryMap = ObjectManager::getInstance()->get(RepositoryMap::class);
468469
return $repositoryMap->getMap($fileId, $params);
469470
}
471+
472+
/**
473+
* @inheritDoc
474+
*/
475+
public function _resetState(): void
476+
{
477+
$this->fallbackContext = [];
478+
$this->fileContext = [];
479+
}
470480
}

0 commit comments

Comments
 (0)