diff --git a/Block/Adminhtml/Report/Edit.php b/Block/Adminhtml/Report/Edit.php index 6cf8fd3..6b40769 100644 --- a/Block/Adminhtml/Report/Edit.php +++ b/Block/Adminhtml/Report/Edit.php @@ -1,6 +1,6 @@ _objectId = 'general_id'; @@ -28,7 +28,7 @@ protected function _construct() parent::_construct(); } - + /** * Retrieve text for header element * diff --git a/Block/Adminhtml/Report/Edit/Form.php b/Block/Adminhtml/Report/Edit/Form.php index fe5f60b..c96d8e7 100644 --- a/Block/Adminhtml/Report/Edit/Form.php +++ b/Block/Adminhtml/Report/Edit/Form.php @@ -1,12 +1,12 @@ setUseContainer(true); $this->setForm($form); - + return parent::_prepareForm(); } } diff --git a/Block/Adminhtml/Report/Edit/Tab/Credentials.php b/Block/Adminhtml/Report/Edit/Tab/Credentials.php index 714a580..0e85c76 100644 --- a/Block/Adminhtml/Report/Edit/Tab/Credentials.php +++ b/Block/Adminhtml/Report/Edit/Tab/Credentials.php @@ -1,6 +1,6 @@ _scopeConfig->isSetFlag('system/full_page_cache/sectionio/include_cms_in_product_purge'); + } + } diff --git a/Model/PurgeCache.php b/Model/PurgeCache.php index 1f2dd8f..58c9154 100644 --- a/Model/PurgeCache.php +++ b/Model/PurgeCache.php @@ -14,6 +14,13 @@ class PurgeCache */ private $logger; + /** + * Application config object + * + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + private $config; + /** @var \Sectionio\Metrics\Helper\State $helper */ protected $state; @@ -27,15 +34,18 @@ class PurgeCache * Constructor * * @param InvalidateLogger $logger + * @param \Sectionio\Metrics\Model\Config $config * @param \Sectionio\Metrics\Helper\State $state * @param \Sectionio\Metrics\Helper\Aperture $aperture */ public function __construct( InvalidateLogger $logger, + \Sectionio\Metrics\Model\Config $config, \Sectionio\Metrics\Helper\State $state, \Sectionio\Metrics\Helper\Aperture $aperture ) { $this->logger = $logger; + $this->config = $config; $this->state = $state; $this->aperture = $aperture; } @@ -54,13 +64,20 @@ public function sendPurgeRequest($tagsPattern) $environment_name = $this->state->getEnvironmentName(); $proxy_name = $this->state->getProxyName(); + $banExpression = urlencode('obj.http.X-Magento-Tags ~ ' . $tagsPattern); + + // If this ban contains product tags & includeCmsInProductPurge is false, exclude any object that also has a CMS Page tag + if (!$this->config->includeCmsInProductPurge() && strpos($tagsPattern, \Magento\Catalog\Model\Product::CACHE_TAG) !== false) { + $banExpression .= urlencode(' && obj.http.X-Magento-Tags !~ (^|,)'.\Magento\Cms\Model\Page::CACHE_TAG.'_[0-9]+'); + } + $uri = $this->aperture->generateUrl([ 'api' => true, 'accountId' => $account_id, 'applicationId' => $application_id, 'environmentName' => $environment_name, 'proxyName' => $proxy_name, - 'uriStem' => '/state?async=true&banExpression=' . urlencode('obj.http.X-Magento-Tags ~ ' . $tagsPattern) + 'uriStem' => '/state?async=true&banExpression=' . $banExpression ]); $info = $this->aperture->executeAuthRequest($uri, 'POST', [], self::BAN_TIMEOUT_SECONDS); @@ -68,7 +85,7 @@ public function sendPurgeRequest($tagsPattern) $this->logger->execute('Error executing purge: ' . $tagsPattern.', Error: ' . $info['body_content']); return false; } - $this->logger->execute(compact('server', 'tagsPattern')); return true; } } + diff --git a/Model/ResourceModel/Account.php b/Model/ResourceModel/Account.php index 780e446..a5fb9aa 100644 --- a/Model/ResourceModel/Account.php +++ b/Model/ResourceModel/Account.php @@ -1,6 +1,6 @@ transactionManager = $context->getTransactionManager(); $this->_resources = $context->getResources(); $this->objectRelationProcessor = $context->getObjectRelationProcessor(); diff --git a/Model/ResourceModel/Account/Collection.php b/Model/ResourceModel/Account/Collection.php index 94c7507..e9b2965 100644 --- a/Model/ResourceModel/Account/Collection.php +++ b/Model/ResourceModel/Account/Collection.php @@ -1,6 +1,6 @@ transactionManager = $context->getTransactionManager(); $this->_resources = $context->getResources(); $this->objectRelationProcessor = $context->getObjectRelationProcessor(); diff --git a/Model/ResourceModel/Application/Collection.php b/Model/ResourceModel/Application/Collection.php index ab7488c..fef56f9 100644 --- a/Model/ResourceModel/Application/Collection.php +++ b/Model/ResourceModel/Application/Collection.php @@ -1,6 +1,6 @@ config = $config; @@ -43,7 +43,7 @@ public function __construct( */ public function execute(\Magento\Framework\Event\Observer $observer) { - if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled()) { + if ($this->config->getType() == \Sectionio\Metrics\Model\Config::VARNISH && $this->config->isEnabled()) { $object = $observer->getEvent()->getObject(); if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) { $tags = []; diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index d6cc694..398de6d 100644 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -1,6 +1,6 @@ - diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index fdb3e87..29882b8 100644 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -1,11 +1,11 @@ - diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100644 index 0000000..88737ad --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,23 @@ + + + + +
+ + + + + + If set to No, CMS pages will not be purged when a product is updated, even if that product is displayed on the page. CMS pages will still be purged if their content is updated. + Magento\Config\Model\Config\Source\Yesno + + + +
+
+
diff --git a/etc/config.xml b/etc/config.xml new file mode 100644 index 0000000..cd6c938 --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,11 @@ + + + + + + 1 + + + + + diff --git a/etc/di.xml b/etc/di.xml index a96f27f..f6e7364 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,7 +1,7 @@ diff --git a/etc/events.xml b/etc/events.xml index 906aac3..dfe413d 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -1,7 +1,7 @@ diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index 7d1e1c9..f0cf631 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,7 +1,7 @@ diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index bb402d7..e22d442 100644 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -1,7 +1,7 @@ diff --git a/etc/module.xml b/etc/module.xml index c2db4cb..1aa5fd5 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,7 +1,7 @@ diff --git a/view/adminhtml/layout/metrics_report_index.xml b/view/adminhtml/layout/metrics_report_index.xml index 7113e7f..4308ec0 100644 --- a/view/adminhtml/layout/metrics_report_index.xml +++ b/view/adminhtml/layout/metrics_report_index.xml @@ -1,7 +1,7 @@