From 1bee29b551b57d5ee3c59f63f2749680aecf431a Mon Sep 17 00:00:00 2001 From: Bas van der Louw Date: Wed, 27 Jan 2021 15:57:27 +0100 Subject: [PATCH] [FEATURE][S-323] Added fallback for e.g., Magento Cloud, where /app directory has no write access --- Helper/Data.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Helper/Data.php b/Helper/Data.php index e85b414..ec55167 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -203,8 +203,16 @@ public function getFileName($locale = 'en_US', $requiredExists = true) $vendor = $this->getLanguageVendor(); $directoryPath = $this->directoryList->getRoot() . '/app/i18n/' . $vendor . '/missing/'; if (!is_dir($directoryPath)) { - mkdir($directoryPath, 0777, true); + @mkdir($directoryPath, 0777, true); } + // Fallback for e.g., Magento Cloud, where /app directory has no write access + if (!is_dir($directoryPath)) { + $directoryPath = $this->directoryList->getRoot() . '/var/i18n/' . $vendor . '/missing/'; + if (!is_dir($directoryPath)) { + @mkdir($directoryPath, 0777, true); + } + } + $filename = $directoryPath . $locale . '.csv'; return (file_exists($filename) || $requiredExists == false) ? $filename : false;