opengento / magento2-store-path-url

This module allows to override the store code in url with an other path value.
MIT License
7 stars 0 forks source link

Memory leak due to native error (from non secure uri) #3

Open thomas-kl1 opened 4 months ago

thomas-kl1 commented 4 months ago

\Magento\Store\Model\Store::isCurrentlySecure

$secureBaseUrl = $this->_config->getValue(self::XML_PATH_SECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
$secureFrontend = $this->_config->getValue(self::XML_PATH_SECURE_IN_FRONTEND, ScopeInterface::SCOPE_STORE);

This methods tries to resolve the configuration from the current active store instead of the internal state ID of the object. Passing the own object ID fix it:

$secureBaseUrl = $this->_config->getValue(self::XML_PATH_SECURE_BASE_URL, ScopeInterface::SCOPE_STORE, $this->getId());
$secureFrontend = $this->_config->getValue(self::XML_PATH_SECURE_IN_FRONTEND, ScopeInterface::SCOPE_STORE, $this->getId());

Because the scope ID is not passed by, Magento core try to resolve the current store ID, which is already what the system is currently trying to achieve.

https://github.com/magento/magento2/pull/38717

thomas-kl1 commented 4 months ago

Add check on https://github.com/opengento/magento2-store-path-url/blob/994cb7f1703b52113a6300da3f29a72e30b79195/Plugin/App/Request/StorePathInfoValidator.php#L30 in order to prevent recursive call of the plugin.

thomas-kl1 commented 4 months ago

Workaround: https://github.com/opengento/magento2-store-path-url/commit/67312b1ec1b4a7a68a5fad78a7fe684c452fbf8a

This change prevent the plugin to be called within the same stack of the parent plugin execution. However it won't fix the Magento cire behavior, meaning that if your are coming from unsecure to secure, the core might be unable to resolve the current scope correctly (native behavior).