From 5d698bf36c28a624c6ccc7a4e3cf8e4db548db4d Mon Sep 17 00:00:00 2001 From: Aakash Kumar Date: Mon, 8 May 2023 12:45:51 -0500 Subject: [PATCH 1/2] ACPT-1184: Fix classes found by GraphQlStateTest --- app/code/Magento/Store/Model/System/Store.php | 10 +++- .../GraphQl/_files/state-skip-list.php | 54 ++++++------------- lib/internal/Magento/Framework/Translate.php | 9 +++- 3 files changed, 33 insertions(+), 40 deletions(-) diff --git a/app/code/Magento/Store/Model/System/Store.php b/app/code/Magento/Store/Model/System/Store.php index a56cdcc37dd54..a678b76238588 100644 --- a/app/code/Magento/Store/Model/System/Store.php +++ b/app/code/Magento/Store/Model/System/Store.php @@ -9,6 +9,7 @@ namespace Magento\Store\Model\System; use Magento\Framework\Data\OptionSourceInterface; +use Magento\Framework\ObjectManager\ResetAfterRequestInterface; /** * Core System Store Model @@ -16,7 +17,7 @@ * @api * @since 100.0.2 */ -class Store extends \Magento\Framework\DataObject implements OptionSourceInterface +class Store extends \Magento\Framework\DataObject implements OptionSourceInterface, ResetAfterRequestInterface { /** * Website collection @@ -533,4 +534,11 @@ private function retrieveOptionValues(array $structure, bool $needSpacePrefix = return $values; } + + public function _resetState(): void + { + $this->_websiteCollection = []; + $this->_groupCollection = []; + $this->_storeCollection = []; + } } diff --git a/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php b/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php index 450662832c75d..d7d32dfd74ef2 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php +++ b/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php @@ -30,21 +30,14 @@ Magento\Framework\GraphQl\Query\Fields::class => null, ], '*' => [ - Magento\Framework\Webapi\Response::class => null, - Magento\TestFramework\App\Filesystem::class => null, Magento\TestFramework\Interception\PluginList::class => null, // memory leak, wrong sql, potential issues - Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Deferred\Product::class => null, - Magento\ConfigurableProductGraphQl\Model\Variant\Collection::class => null, - Magento\ConfigurableProductGraphQl\Model\Options\Collection::class => null, - Magento\Framework\Url\QueryParamsResolver::class => null, Magento\Framework\Event\Config\Data::class => null, // TODO: reset when config is reset from poison pill Magento\Framework\App\AreaList::class => null, 'customRemoteFilesystem' => null, Magento\Store\App\Config\Type\Scopes::class => null, Magento\Framework\Module\Dir\Reader::class => null, Magento\Framework\App\Language\Dictionary::class => null, - Magento\Framework\Code\Reader\ClassReader::class => null, Magento\Framework\ObjectManager\ConfigInterface::class => null, Magento\Framework\App\Cache\Type\Config::class => null, Magento\Framework\Interception\PluginListGenerator::class => null, @@ -52,8 +45,6 @@ Magento\TestFramework\Request::class => null, Magento\Framework\View\FileSystem::class => null, Magento\Framework\App\Config\FileResolver::class => null, - Magento\Framework\Module\Manager::class => null, - Magento\Framework\Logger\LoggerProxy::class => null, Magento\TestFramework\ErrorLog\Logger::class => null, 'translationConfigSourceAggregated' => null, Magento\Framework\App\Request\Http\Proxy::class => null, @@ -67,39 +58,26 @@ Magento\Framework\Locale\Resolver\Proxy::class => null, Magento\MediaStorage\Helper\File\Storage\Database::class => null, Magento\Framework\App\Cache\Proxy::class => null, - Magento\Framework\Translate::class => null, // TODO: ? - Magento\Store\Model\StoreManager::class => null, // TODO: This is reset with poison pill, right? - Magento\Framework\App\Http\Context::class => null, // TODO: This should probably be cleaned up, right?!? - Magento\Customer\Model\Session\Storage::class => null, // TODO: Didn't Aakash or Kasian fix this already? - Magento\TestFramework\Response::class => null, // TODO: Why is this in the ObjectManager?!? - Magento\Store\Model\WebsiteRepository::class => null, // TODO: What is going on here?!? - Magento\Framework\Locale\Resolver::class => null, // TODO: do we need to fix this? - Magento\Theme\Model\ResourceModel\Theme\Collection::class => null, // TODO - Magento\Store\Model\GroupRepository::class => null, // TODO: see what this is - Magento\Store\Model\StoreRepository::class => null, // TODO: could be fixed already with Poison Pill + Magento\Framework\Translate::class => null, + Magento\Store\Model\StoreManager::class => null, + Magento\Framework\App\Http\Context::class => null, + Magento\TestFramework\Response::class => null, + Magento\Store\Model\WebsiteRepository::class => null, + Magento\Framework\Locale\Resolver::class => null, + Magento\Store\Model\GroupRepository::class => null, + Magento\Store\Model\StoreRepository::class => null, Magento\Framework\View\Design\Fallback\RulePool::class => null, // TODO: Looks like we need to reset? - Magento\Framework\View\Asset\Repository::class => null, // TODO: Looks okay, but need to confirm - Magento\Framework\HTTP\Header::class => null, // TODO: I believe Aakash is currently working on this + Magento\Framework\View\Asset\Repository::class => null, + Magento\Framework\HTTP\Header::class => null, Magento\Framework\App\Route\Config::class => null, // TODO: reset when Poison Pill causes config to reset. - Magento\Customer\Model\ResourceModel\Attribute::class => null, // TODO - Magento\Framework\DataObject\Copy\Config\Converter::class => null, // TODO - Magento\Framework\DataObject\Copy\Config\SchemaLocator::class => null, // TODO - Magento\Framework\DataObject\Copy\Config\Reader::class => null, // TODO - Magento\Framework\DataObject\Copy\Config\Data::class => null, // TODO - Magento\Store\Model\System\Store::class => null, // TODO + Magento\Store\Model\System\Store::class => null, Magento\AwsS3\Driver\CredentialsCache::class => null, // TODO - Magento\Eav\Model\Config::class => null, // TODO: Does this work properly after config changes? + Magento\Eav\Model\Config::class => null, 'AssetPreProcessorPool' => null, // TODO: see what this is - Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider::class => null, // FIXME: bug? - Magento\GraphQl\Model\Query\Context::class => null, // FIXME: I think this one needs to be reset. Check! - Magento\GraphQl\Model\Query\ContextFactory::class => null, // FIXME: I think this one needs to be reset. Check! - 'viewFileMinifiedFallbackResolver' => null, // FIXME: remove after fix for Framework\View\Asset\Minification - Magento\Framework\View\Asset\Minification::class => null, // FIXME: $configCache must be reset - // FIXME: We MUST NOT dependency inject collections. - // This needs to be fixed in Magento\CatalogGraphQl\Model\Config\SortAttributeReader - Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class => null, - Magento\Framework\Url::class => null, // FIXME: This need reseter!! - Magento\Quote\Model\Quote\Address\Total\Collector::class => null, // FIXME: mutable state that needs to be reset + Magento\GraphQl\Model\Query\ContextFactory::class => null, + 'viewFileMinifiedFallbackResolver' => null, + Magento\Framework\View\Asset\Minification::class => null, + Magento\Framework\Url::class => null, Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class => null, // FIXME: caching from $request ], '' => [ diff --git a/lib/internal/Magento/Framework/Translate.php b/lib/internal/Magento/Framework/Translate.php index ea0911eb7000b..2efc11bc7d43a 100644 --- a/lib/internal/Magento/Framework/Translate.php +++ b/lib/internal/Magento/Framework/Translate.php @@ -11,6 +11,7 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\Filesystem\Driver\File; use Magento\Framework\Filesystem\DriverInterface; +use Magento\Framework\ObjectManager\ResetAfterRequestInterface; /** * Translate library @@ -18,7 +19,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class Translate implements \Magento\Framework\TranslateInterface +class Translate implements \Magento\Framework\TranslateInterface, ResetAfterRequestInterface { const CONFIG_AREA_KEY = 'area'; const CONFIG_LOCALE_KEY = 'locale'; @@ -601,4 +602,10 @@ private function getSerializer() } return $this->serializer; } + + public function _resetState(): void + { + $this->_config = []; + $this->_data = []; + } } From 121046abff7b09e57322cba6e4ce289dfb96dd70 Mon Sep 17 00:00:00 2001 From: Aakash Kumar Date: Tue, 9 May 2023 11:58:09 -0500 Subject: [PATCH 2/2] ACPT-1184: Fix classes found by GraphQlStateTest --- app/code/Magento/Store/Model/System/Store.php | 10 +--------- .../Magento/GraphQl/_files/state-skip-list.php | 13 +++++++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Store/Model/System/Store.php b/app/code/Magento/Store/Model/System/Store.php index a678b76238588..a56cdcc37dd54 100644 --- a/app/code/Magento/Store/Model/System/Store.php +++ b/app/code/Magento/Store/Model/System/Store.php @@ -9,7 +9,6 @@ namespace Magento\Store\Model\System; use Magento\Framework\Data\OptionSourceInterface; -use Magento\Framework\ObjectManager\ResetAfterRequestInterface; /** * Core System Store Model @@ -17,7 +16,7 @@ * @api * @since 100.0.2 */ -class Store extends \Magento\Framework\DataObject implements OptionSourceInterface, ResetAfterRequestInterface +class Store extends \Magento\Framework\DataObject implements OptionSourceInterface { /** * Website collection @@ -534,11 +533,4 @@ private function retrieveOptionValues(array $structure, bool $needSpacePrefix = return $values; } - - public function _resetState(): void - { - $this->_websiteCollection = []; - $this->_groupCollection = []; - $this->_storeCollection = []; - } } diff --git a/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php b/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php index d7d32dfd74ef2..3225a27f41365 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php +++ b/dev/tests/integration/testsuite/Magento/GraphQl/_files/state-skip-list.php @@ -32,7 +32,7 @@ '*' => [ Magento\TestFramework\Interception\PluginList::class => null, // memory leak, wrong sql, potential issues - Magento\Framework\Event\Config\Data::class => null, // TODO: reset when config is reset from poison pill + Magento\Framework\Event\Config\Data::class => null, Magento\Framework\App\AreaList::class => null, 'customRemoteFilesystem' => null, Magento\Store\App\Config\Type\Scopes::class => null, @@ -66,19 +66,20 @@ Magento\Framework\Locale\Resolver::class => null, Magento\Store\Model\GroupRepository::class => null, Magento\Store\Model\StoreRepository::class => null, - Magento\Framework\View\Design\Fallback\RulePool::class => null, // TODO: Looks like we need to reset? + Magento\Framework\View\Design\Fallback\RulePool::class => null, Magento\Framework\View\Asset\Repository::class => null, Magento\Framework\HTTP\Header::class => null, - Magento\Framework\App\Route\Config::class => null, // TODO: reset when Poison Pill causes config to reset. + Magento\Framework\App\Route\Config::class => null, Magento\Store\Model\System\Store::class => null, - Magento\AwsS3\Driver\CredentialsCache::class => null, // TODO + Magento\AwsS3\Driver\CredentialsCache::class => null, Magento\Eav\Model\Config::class => null, - 'AssetPreProcessorPool' => null, // TODO: see what this is + 'AssetPreProcessorPool' => null, Magento\GraphQl\Model\Query\ContextFactory::class => null, 'viewFileMinifiedFallbackResolver' => null, Magento\Framework\View\Asset\Minification::class => null, + Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class => null, Magento\Framework\Url::class => null, - Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class => null, // FIXME: caching from $request + Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class => null, ], '' => [ ],