diff -Nuar a/vendor/magento/module-page-builder/Block/WysiwygSetup.php b/vendor/magento/module-page-builder/Block/WysiwygSetup.php
index 61bb82b61..d30a0979c 100644
--- a/vendor/magento/module-page-builder/Block/WysiwygSetup.php
+++ b/vendor/magento/module-page-builder/Block/WysiwygSetup.php
@@ -8,9 +8,13 @@ declare(strict_types=1);
namespace Magento\PageBuilder\Block;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Cache\FrontendInterface;
use Magento\Framework\DataObject;
use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\PageBuilder\Model\Session\RandomKey;
+use Magento\Ui\Component\Wysiwyg\ConfigInterface;
/**
* @api
@@ -20,7 +24,7 @@ class WysiwygSetup extends Template
private const WYSIWYG_CONFIG_CACHE_ID = 'WYSIWYG_CONFIG';
/**
- * @var \Magento\Ui\Component\Wysiwyg\ConfigInterface
+ * @var ConfigInterface
*/
private $config;
@@ -30,19 +34,28 @@ class WysiwygSetup extends Template
private $cache;
/**
- * @param Template\Context $context
- * @param \Magento\Ui\Component\Wysiwyg\ConfigInterface $config
+ * @var RandomKey
+ */
+ private $sessionRandomKey;
+
+ /**
+ * @param Context $context
+ * @param ConfigInterface $config
* @param array $data
* @param FrontendInterface|null $cache
+ * @param RandomKey|null $sessionRandomKey
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Ui\Component\Wysiwyg\ConfigInterface $config,
+ Context $context,
+ ConfigInterface $config,
array $data = [],
- FrontendInterface $cache = null
+ FrontendInterface $cache = null,
+ ?RandomKey $sessionRandomKey = null
) {
$this->config = $config;
- $this->cache = $cache ?: \Magento\Framework\App\ObjectManager::getInstance()->get(FrontendInterface::class);
+ $this->cache = $cache ?: ObjectManager::getInstance()->get(FrontendInterface::class);
+ $this->sessionRandomKey = $sessionRandomKey
+ ?: ObjectManager::getInstance()->get(RandomKey::class);
parent::__construct($context, $data);
}
@@ -53,14 +66,18 @@ class WysiwygSetup extends Template
*/
public function getConfigJson() : string
{
- $configJson = $this->cache->load(self::WYSIWYG_CONFIG_CACHE_ID);
+ $cacheKey = self::WYSIWYG_CONFIG_CACHE_ID;
+ if ($this->_urlBuilder->useSecretKey()) {
+ $cacheKey .= '_' . $this->sessionRandomKey->getValue();
+ }
+ $configJson = $this->cache->load($cacheKey);
if (!$configJson) {
$config = $this->config->getConfig();
if (is_array($config)) {
$config = new DataObject($config);
}
$configJson = $config->toJson();
- $this->cache->save($configJson, self::WYSIWYG_CONFIG_CACHE_ID);
+ $this->cache->save($configJson, $cacheKey);
}
return $configJson;
diff -Nuar a/vendor/magento/module-page-builder/Model/EditorConfigCacheCleaner.php b/vendor/magento/module-page-builder/Model/EditorConfigCacheCleaner.php
new file mode 100644
index 000000000..da8bbcc92
--- /dev/null
+++ b/vendor/magento/module-page-builder/Model/EditorConfigCacheCleaner.php
@@ -0,0 +1,38 @@
+cache = $cache;
+ }
+
+ /**
+ * Clean page builder config cache
+ */
+ public function execute(): void
+ {
+ $this->cache->clean();
+ }
+}
diff -Nuar a/vendor/magento/module-page-builder/Model/Session/RandomKey.php b/vendor/magento/module-page-builder/Model/Session/RandomKey.php
new file mode 100644
index 000000000..6c93abeef
--- /dev/null
+++ b/vendor/magento/module-page-builder/Model/Session/RandomKey.php
@@ -0,0 +1,83 @@
+random = $random;
+ $this->session = $session;
+ $this->keyName = $keyName;
+ $this->keyLength = $keyLength;
+ }
+
+ /**
+ * Retrieve generated random key from session
+ *
+ * @return string
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ public function getValue(): string
+ {
+ $randomKey = $this->session->getData($this->keyName);
+ if (!$randomKey) {
+ $randomKey = $this->random->getRandomString($this->keyLength);
+ $this->session->setData($this->keyName, $randomKey);
+ }
+ return $randomKey;
+ }
+}
diff -Nuar a/vendor/magento/module-page-builder/Model/Stage/Config.php b/vendor/magento/module-page-builder/Model/Stage/Config.php
index 8f208c654..014208277 100644
--- a/vendor/magento/module-page-builder/Model/Stage/Config.php
+++ b/vendor/magento/module-page-builder/Model/Stage/Config.php
@@ -13,6 +13,7 @@ use Magento\Framework\UrlInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Cache\FrontendInterface;
use Magento\Framework\Serialize\Serializer\Json;
+use Magento\PageBuilder\Model\Session\RandomKey;
/**
* Provide configuration to the admin JavaScript app
@@ -120,6 +121,11 @@ class Config
private $serializer;
/**
+ * @var RandomKey
+ */
+ private $sessionRandomKey;
+
+ /**
* @param \Magento\PageBuilder\Model\ConfigInterface $config
* @param Config\UiComponentConfig $uiComponentConfig
* @param UrlInterface $urlBuilder
@@ -136,6 +142,7 @@ class Config
* @param AuthorizationInterface|null $authorization
* @param FrontendInterface|null $cache
* @param Json|null $serializer
+ * @param RandomKey|null $sessionRandomKey
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
@@ -155,7 +162,8 @@ class Config
\Magento\Variable\Model\Variable\Config $variableConfig = null,
AuthorizationInterface $authorization = null,
FrontendInterface $cache = null,
- Json $serializer = null
+ Json $serializer = null,
+ ?RandomKey $sessionRandomKey = null
) {
$this->config = $config;
$this->uiComponentConfig = $uiComponentConfig;
@@ -175,6 +183,8 @@ class Config
$this->authorization = $authorization ?: ObjectManager::getInstance()->get(AuthorizationInterface::class);
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class);
$this->cache = $cache ?: \Magento\Framework\App\ObjectManager::getInstance()->get(FrontendInterface::class);
+ $this->sessionRandomKey = $sessionRandomKey
+ ?: \Magento\Framework\App\ObjectManager::getInstance()->get(RandomKey::class);
}
/**
@@ -394,6 +404,9 @@ class Config
*/
private function getCache(string $cacheIdentifier): array
{
+ if ($this->urlBuilder->useSecretKey()) {
+ $cacheIdentifier .= '_' . $this->sessionRandomKey->getValue();
+ }
$serializedData = $this->cache->load($cacheIdentifier);
$cache = $serializedData
? $this->serializer->unserialize($serializedData)
@@ -410,6 +423,9 @@ class Config
*/
private function saveCache(array $data, string $cacheIdentifier): void
{
+ if ($this->urlBuilder->useSecretKey()) {
+ $cacheIdentifier .= '_' . $this->sessionRandomKey->getValue();
+ }
$this->cache->save($this->serializer->serialize($data), $cacheIdentifier);
}
}
diff -Nuar a/vendor/magento/module-page-builder/Plugin/ClearEditorConfigCache.php b/vendor/magento/module-page-builder/Plugin/ClearEditorConfigCache.php
new file mode 100644
index 000000000..19c0944e2
--- /dev/null
+++ b/vendor/magento/module-page-builder/Plugin/ClearEditorConfigCache.php
@@ -0,0 +1,52 @@
+cacheCleaner = $cacheCleaner;
+ $this->backendUrl = $backendUrl;
+ }
+
+ /**
+ * Clear page builder editor config cache after login
+ *
+ * @param \Magento\Backend\Model\Auth $subject
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterLogin(\Magento\Backend\Model\Auth $subject): void
+ {
+ if ($this->backendUrl->useSecretKey()) {
+ $this->cacheCleaner->execute();
+ }
+ }
+}
diff -Nuar a/vendor/magento/module-page-builder/etc/adminhtml/di.xml b/vendor/magento/module-page-builder/etc/adminhtml/di.xml
index 1786a86f8..6d1c0e737 100644
--- a/vendor/magento/module-page-builder/etc/adminhtml/di.xml
+++ b/vendor/magento/module-page-builder/etc/adminhtml/di.xml
@@ -623,4 +623,8 @@
+
+
+
diff -Nuar a/vendor/magento/module-page-builder/etc/di.xml b/vendor/magento/module-page-builder/etc/di.xml
index 8096eb1f9..22540164f 100644
--- a/vendor/magento/module-page-builder/etc/di.xml
+++ b/vendor/magento/module-page-builder/etc/di.xml
@@ -26,14 +26,25 @@
+
+
+ Magento\Framework\App\Cache\Type\Config
+ PB_EDITOR_CONFIG
+
+
+
+
+ Magento\PageBuilder\Model\Cache\Type\EditorConfig
+
+
- Magento\Framework\App\Cache\Type\Config
+ Magento\PageBuilder\Model\Cache\Type\EditorConfig
- Magento\Framework\App\Cache\Type\Config
+ Magento\PageBuilder\Model\Cache\Type\EditorConfig