Index: vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CountryTagGenerator.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CountryTagGenerator.php b/vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CountryTagGenerator.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CountryTagGenerator.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,65 @@ +storeManager = $storeManager; + } + + /** + * @inheritdoc + */ + public function generateTags(ValueInterface $config): array + { + if (in_array($config->getPath(), $this->countryConfigPaths)) { + if ($config->getScope() == ScopeInterface::SCOPE_WEBSITES) { + $website = $this->storeManager->getWebsite($config->getScopeId()); + $storeIds = $website->getStoreIds(); + } elseif ($config->getScope() == ScopeInterface::SCOPE_STORES) { + $storeIds = [$config->getScopeId()]; + } else { + $storeIds = array_keys($this->storeManager->getStores()); + } + $tags = []; + foreach ($storeIds as $storeId) { + $tags[] = sprintf('%s_%s', Identity::CACHE_TAG, $storeId); + } + return $tags; + } + return []; + } +} Index: vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CurrencyTagGenerator.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CurrencyTagGenerator.php b/vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CurrencyTagGenerator.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-directory-graph-ql/Model/Cache/Tag/Strategy/Config/CurrencyTagGenerator.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,67 @@ +storeManager = $storeManager; + } + + /** + * @inheritdoc + */ + public function generateTags(ValueInterface $config): array + { + if (in_array($config->getPath(), $this->currencyConfigPaths)) { + if ($config->getScope() == ScopeInterface::SCOPE_WEBSITES) { + $website = $this->storeManager->getWebsite($config->getScopeId()); + $storeIds = $website->getStoreIds(); + } elseif ($config->getScope() == ScopeInterface::SCOPE_STORES) { + $storeIds = [$config->getScopeId()]; + } else { + $storeIds = array_keys($this->storeManager->getStores()); + } + $tags = []; + foreach ($storeIds as $storeId) { + $tags[] = sprintf('%s_%s', Identity::CACHE_TAG, $storeId); + } + return $tags; + } + return []; + } +} Index: vendor/magento/module-directory-graph-ql/Model/Resolver/Country/Identity.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-directory-graph-ql/Model/Resolver/Country/Identity.php b/vendor/magento/module-directory-graph-ql/Model/Resolver/Country/Identity.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-directory-graph-ql/Model/Resolver/Country/Identity.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,44 @@ +storeManager = $storeManager; + } + + /** + * @inheritdoc + */ + public function getIdentities(array $resolvedData): array + { + if (empty($resolvedData)) { + return []; + } + $storeId = $this->storeManager->getStore()->getId(); + return [self::CACHE_TAG, sprintf('%s_%s', self::CACHE_TAG, $storeId)]; + } +} Index: vendor/magento/module-directory-graph-ql/Model/Resolver/Currency/Identity.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-directory-graph-ql/Model/Resolver/Currency/Identity.php b/vendor/magento/module-directory-graph-ql/Model/Resolver/Currency/Identity.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-directory-graph-ql/Model/Resolver/Currency/Identity.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,44 @@ +storeManager = $storeManager; + } + + /** + * @inheritdoc + */ + public function getIdentities(array $resolvedData): array + { + if (empty($resolvedData)) { + return []; + } + $storeId = $this->storeManager->getStore()->getId(); + return [self::CACHE_TAG, sprintf('%s_%s', self::CACHE_TAG, $storeId)]; + } +} Index: vendor/magento/module-directory-graph-ql/Plugin/Currency.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-directory-graph-ql/Plugin/Currency.php b/vendor/magento/module-directory-graph-ql/Plugin/Currency.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-directory-graph-ql/Plugin/Currency.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,56 @@ +eventManager = $eventManager; + } + + /** + * Trigger clean cache by tags after save rates + * + * @param CurrencyModel $subject + * @param CurrencyModel $result + * @return CurrencyModel + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterSaveRates(CurrencyModel $subject, CurrencyModel $result): CurrencyModel + { + $this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this]); + return $result; + } + + /** + * @inheritdoc + */ + public function getIdentities() + { + return [Identity::CACHE_TAG]; + } +} Index: vendor/magento/module-directory-graph-ql/etc/di.xml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-directory-graph-ql/etc/di.xml b/vendor/magento/module-directory-graph-ql/etc/di.xml new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-directory-graph-ql/etc/di.xml (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,24 @@ + + + + + + + + Magento\DirectoryGraphQl\Model\Cache\Tag\Strategy\Config\CurrencyTagGenerator + + + Magento\DirectoryGraphQl\Model\Cache\Tag\Strategy\Config\CountryTagGenerator + + + + + + + + Index: vendor/magento/module-directory-graph-ql/etc/schema.graphqls IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-directory-graph-ql/etc/schema.graphqls b/vendor/magento/module-directory-graph-ql/etc/schema.graphqls --- a/vendor/magento/module-directory-graph-ql/etc/schema.graphqls (revision fc35000d1dc61dbf65b0f8f49b802074073686a7) +++ b/vendor/magento/module-directory-graph-ql/etc/schema.graphqls (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -2,9 +2,9 @@ # See COPYING.txt for license details. type Query { - currency: Currency @resolver(class: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Currency") @doc(description: "Return information about the store's currency.") @cache(cacheable: false) - countries: [Country] @resolver(class: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Countries") @doc(description: "The countries query provides information for all countries.") @cache(cacheable: false) - country (id: String): Country @resolver(class: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Country") @doc(description: "The countries query provides information for a single country.") @cache(cacheable: false) + currency: Currency @resolver(class: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Currency") @doc(description: "Return information about the store's currency.") @cache(cacheIdentity: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Currency\\Identity") + countries: [Country] @resolver(class: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Countries") @doc(description: "The countries query provides information for all countries.") @cache(cacheIdentity: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Country\\Identity") + country (id: String): Country @resolver(class: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Country") @doc(description: "The countries query provides information for a single country.") @cache(cacheIdentity: "Magento\\DirectoryGraphQl\\Model\\Resolver\\Country\\Identity") } type Currency { Index: vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/CompositeTagGenerator.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/CompositeTagGenerator.php b/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/CompositeTagGenerator.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/CompositeTagGenerator.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,42 @@ +tagGenerators = $tagGenerators; + } + + /** + * @inheritdoc + */ + public function generateTags(ValueInterface $config): array + { + $tagsArray = []; + foreach ($this->tagGenerators as $tagGenerator) { + $tagsArray[] = $tagGenerator->generateTags($config); + } + return array_merge(...$tagsArray); + } +} Index: vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/StoreConfig.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/StoreConfig.php b/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/StoreConfig.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/StoreConfig.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,47 @@ +tagGenerator = $tagGenerator; + } + + /** + * @inheritdoc + */ + public function getTags($object): array + { + if (!is_object($object)) { + throw new \InvalidArgumentException('Provided argument is not an object'); + } + + if ($object instanceof ValueInterface && $object->isValueChanged()) { + return $this->tagGenerator->generateTags($object); + } + + return []; + } +} Index: vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/TagGeneratorInterface.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/TagGeneratorInterface.php b/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/TagGeneratorInterface.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store/Model/Config/Cache/Tag/Strategy/TagGeneratorInterface.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,24 @@ +UTF-8 =================================================================== diff --git a/vendor/magento/module-store/etc/di.xml b/vendor/magento/module-store/etc/di.xml --- a/vendor/magento/module-store/etc/di.xml (revision fc35000d1dc61dbf65b0f8f49b802074073686a7) +++ b/vendor/magento/module-store/etc/di.xml (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -457,4 +457,20 @@ + + + + + Magento\Store\Model\Config\Cache\Tag\Strategy\StoreConfig + + + + + + + + Magento\Store\Model\Config\Cache\Tag\Strategy\CompositeTagGenerator + + + Index: vendor/magento/module-store-graph-ql/Model/Cache/Tag/Strategy/ConfigTagGenerator.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/Model/Cache/Tag/Strategy/ConfigTagGenerator.php b/vendor/magento/module-store-graph-ql/Model/Cache/Tag/Strategy/ConfigTagGenerator.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store-graph-ql/Model/Cache/Tag/Strategy/ConfigTagGenerator.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,54 @@ +storeManager = $storeManager; + } + + /** + * @inheritdoc + */ + public function generateTags(ValueInterface $config): array + { + if ($config->getScope() == ScopeInterface::SCOPE_WEBSITES) { + $website = $this->storeManager->getWebsite($config->getScopeId()); + $storeIds = $website->getStoreIds(); + } elseif ($config->getScope() == ScopeInterface::SCOPE_STORES) { + $storeIds = [$config->getScopeId()]; + } else { + $storeIds = array_keys($this->storeManager->getStores()); + } + $tags = []; + foreach ($storeIds as $storeId) { + $tags[] = sprintf('%s_%s', ConfigIdentity::CACHE_TAG, $storeId); + } + return $tags; + } +} Index: vendor/magento/module-store-graph-ql/Model/Resolver/Store/ConfigIdentity.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/Model/Resolver/Store/ConfigIdentity.php b/vendor/magento/module-store-graph-ql/Model/Resolver/Store/ConfigIdentity.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store-graph-ql/Model/Resolver/Store/ConfigIdentity.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,29 @@ +UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/Model/Resolver/Stores/ConfigIdentity.php b/vendor/magento/module-store-graph-ql/Model/Resolver/Stores/ConfigIdentity.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store-graph-ql/Model/Resolver/Stores/ConfigIdentity.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,73 @@ +storeManager = $storeManager; + } + + /** + * @inheritDoc + */ + public function getIdentities(array $resolvedData): array + { + $ids = []; + foreach ($resolvedData as $storeConfig) { + $ids[] = sprintf('%s_%s', StoreConfigIdentity::CACHE_TAG, $storeConfig['id']); + } + if (!empty($resolvedData)) { + $websiteId = $resolvedData[0]['website_id']; + $currentStoreGroupId = $this->getCurrentStoreGroupId($resolvedData); + $groupTag = $currentStoreGroupId ? 'group_' . $currentStoreGroupId : ''; + $ids[] = sprintf('%s_%s', StoreConfigIdentity::CACHE_TAG, 'website_' . $websiteId . $groupTag); + } + + return empty($ids) ? [] : array_merge([StoreConfigIdentity::CACHE_TAG], $ids); + } + + /** + * Return current store group id if it is certain that useCurrentGroup is true in the query + * + * @param array $resolvedData + * @return string|int|null + */ + private function getCurrentStoreGroupId(array $resolvedData) + { + $storeGroupCodes = array_unique(array_column($resolvedData, 'store_group_code')); + if (count($storeGroupCodes) == 1) { + try { + $store = $this->storeManager->getStore($resolvedData[0]['id']); + if ($store->getWebsite()->getGroupCollection()->count() != 1) { + // There are multiple store groups in the website while there is only one store group + // in the resolved data. Therefore useCurrentGroup must be true in the query + return $store->getStoreGroupId(); + } + } catch (NoSuchEntityException $e) { + // Do nothing + ; + } + } + return null; + } +} Index: vendor/magento/module-store-graph-ql/Plugin/Group.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/Plugin/Group.php b/vendor/magento/module-store-graph-ql/Plugin/Group.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store-graph-ql/Plugin/Group.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,40 @@ +getStoreIds(); + if (count($storeIds) > 0) { + foreach ($storeIds as $storeId) { + $result[] = sprintf('%s_%s', ConfigIdentity::CACHE_TAG, $storeId); + } + $origWebsiteId = $subject->getOrigData('website_id'); + $websiteId = $subject->getWebsiteId(); + if ($origWebsiteId != $websiteId) { // Add or switch to a new website + $result[] = sprintf('%s_%s', ConfigIdentity::CACHE_TAG, 'website_' . $websiteId); + } + } + + return $result; + } +} Index: vendor/magento/module-store-graph-ql/Plugin/Store.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/Plugin/Store.php b/vendor/magento/module-store-graph-ql/Plugin/Store.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store-graph-ql/Plugin/Store.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,62 @@ +getId()); + + $isActive = $subject->getIsActive(); + // New active store or newly activated store or an active store switched store group + if ($isActive + && ($subject->getOrigData('is_active') !== $isActive || $this->isStoreGroupSwitched($subject)) + ) { + $websiteId = $subject->getWebsiteId(); + if ($websiteId !== null) { + $result[] = sprintf('%s_%s', ConfigIdentity::CACHE_TAG, 'website_' . $websiteId); + $storeGroupId = $subject->getStoreGroupId(); + if ($storeGroupId !== null) { + $result[] = sprintf( + '%s_%s', + ConfigIdentity::CACHE_TAG, + 'website_' . $websiteId . 'group_' . $storeGroupId + ); + } + } + } + + return $result; + } + + /** + * Check whether the store group of the store is switched + * + * @param \Magento\Store\Model\Store $store + * @return bool + */ + private function isStoreGroupSwitched(\Magento\Store\Model\Store $store): bool + { + $origStoreGroupId = $store->getOrigData('group_id'); + $storeGroupId = $store->getStoreGroupId(); + return $origStoreGroupId != null && $origStoreGroupId != $storeGroupId; + } +} Index: vendor/magento/module-store-graph-ql/Plugin/Website.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/Plugin/Website.php b/vendor/magento/module-store-graph-ql/Plugin/Website.php new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store-graph-ql/Plugin/Website.php (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,32 @@ +getStoreIds(); + foreach ($storeIds as $storeId) { + $result[] = sprintf('%s_%s', ConfigIdentity::CACHE_TAG, $storeId); + } + return $result; + } +} Index: vendor/magento/module-store-graph-ql/etc/di.xml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/etc/di.xml b/vendor/magento/module-store-graph-ql/etc/di.xml new file mode 100644 --- /dev/null (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) +++ b/vendor/magento/module-store-graph-ql/etc/di.xml (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -0,0 +1,27 @@ + + + + + + + + Magento\StoreGraphQl\Model\Cache\Tag\Strategy\ConfigTagGenerator + + + + + + + + + + + + + + Index: vendor/magento/module-store-graph-ql/etc/schema.graphqls IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/vendor/magento/module-store-graph-ql/etc/schema.graphqls b/vendor/magento/module-store-graph-ql/etc/schema.graphqls --- a/vendor/magento/module-store-graph-ql/etc/schema.graphqls (revision fc35000d1dc61dbf65b0f8f49b802074073686a7) +++ b/vendor/magento/module-store-graph-ql/etc/schema.graphqls (revision 1c05bb0ac1970f056e159f4396b154f5a6187892) @@ -1,10 +1,10 @@ # Copyright © Magento, Inc. All rights reserved. # See COPYING.txt for license details. type Query { - storeConfig : StoreConfig @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\StoreConfigResolver") @doc(description: "Return details about the store's configuration.") @cache(cacheable: false) + storeConfig : StoreConfig @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\StoreConfigResolver") @doc(description: "Return details about the store's configuration.") @cache(cacheIdentity: "Magento\\StoreGraphQl\\Model\\Resolver\\Store\\ConfigIdentity") availableStores( useCurrentGroup: Boolean @doc(description: "Filter store views by the current store group.") - ): [StoreConfig] @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\AvailableStoresResolver") @doc(description: "Get a list of available store views and their config information.") + ): [StoreConfig] @resolver(class: "Magento\\StoreGraphQl\\Model\\Resolver\\AvailableStoresResolver") @doc(description: "Get a list of available store views and their config information.") @cache(cacheIdentity: "Magento\\StoreGraphQl\\Model\\Resolver\\Stores\\ConfigIdentity") } type Website @doc(description: "Deprecated. It should not be used on the storefront. Contains information about a website.") {