Skip to content

Instantly share code, notes, and snippets.

@mpchadwick
Created June 18, 2020 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpchadwick/a0a18775e99a3f112f257b53db7a6075 to your computer and use it in GitHub Desktop.
Save mpchadwick/a0a18775e99a3f112f257b53db7a6075 to your computer and use it in GitHub Desktop.
diff --git a/vendor/magento/module-media-storage/App/Media.php b/vendor/magento/module-media-storage/App/Media.php
index e1644ebaf5a..5993deecfd2 100644
--- a/vendor/magento/module-media-storage/App/Media.php
+++ b/vendor/magento/module-media-storage/App/Media.php
@@ -141,10 +141,10 @@ class Media implements AppInterface
{
$this->appState->setAreaCode(Area::AREA_GLOBAL);
- if ($this->mediaDirectoryPath !== $this->directory->getAbsolutePath()) {
+ $config = $this->configFactory->create(['cacheFile' => $this->configCacheFile]);
+ if (!$this->comparePaths($this->mediaDirectoryPath, $config->getMediaDirectory())) {
// Path to media directory changed or absent - update the config
/** @var Config $config */
- $config = $this->configFactory->create(['cacheFile' => $this->configCacheFile]);
$config->save();
$this->mediaDirectoryPath = $config->getMediaDirectory();
$allowedResources = $config->getAllowedResources();
@@ -171,6 +171,18 @@ class Media implements AppInterface
return $this->response;
}
+ /**
+ * @param string $path1
+ * @param string $path2
+ * @return bool
+ */
+ private function comparePaths($path1, $path2)
+ {
+ if (rtrim($path1, '/') == rtrim($path2, '/'))
+ return true;
+ return false;
+ }
+
private function setPlaceholderImage()
{
$placeholder = $this->placeholderFactory->create(['type' => 'image']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment