EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Metadata save error file path
Yurii2b1daf37423f
diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.phpindex 76c6365745..8f206e681a 100644--- a/application/Espo/Core/Utils/Metadata.php+++ b/application/Espo/Core/Utils/Metadata.php@@ -345,46 +345,52 @@ class Metadata*/public function save(): bool{- $path = $this->customPath;-$result = true;+ $problemPath = null;- if (!empty($this->changedData)) {+ if ($this->changedData) {foreach ($this->changedData as $key1 => $keyData) {foreach ($keyData as $key2 => $data) {if (empty($data)) {continue;}- $filePath = "$path/$key1/$key2.json";+ $filePath = "$this->customPath/$key1/$key2.json";++ $itemResult = $this->fileManager->mergeJsonContents($filePath, $data);++ $result &= $itemResult;- $result &= $this->fileManager->mergeJsonContents($filePath, $data);+ if (!$itemResult && !$problemPath) {+ $problemPath = $filePath;+ }}}}- if (!empty($this->deletedData)) {+ if ($this->deletedData) {foreach ($this->deletedData as $key1 => $keyData) {foreach ($keyData as $key2 => $unsetData) {if (empty($unsetData)) {continue;}- $filePath = "$path/$key1/$key2.json";+ $filePath = "$this->customPath/$key1/$key2.json";$rowResult = $this->fileManager->unsetJsonContents($filePath, $unsetData);if (!$rowResult) {- throw new LogicException(- "Metadata items $key1.$key2 can be deleted for custom code only."- );+ throw new LogicException("Metadata items $key1.$key2 can be deleted for custom code only.");}}}}if (!$result) {- throw new RuntimeException("Error while saving metadata. See log file for details.");+ $message = "Error while saving metadata. Usually it's a file permission problem. " .+ "First problem path: `$problemPath`.";++ throw new RuntimeException($message);}$this->clearChanges();