From 1b6c8a6b7ee30d35ace96d54ea24f520603bb10c Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Fri, 30 Sep 2022 10:03:28 +0100 Subject: [PATCH 1/3] Check if remote storage is enabled before saving local file --- get.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/get.php b/get.php index 173616922d1..530305e15fc 100644 --- a/get.php +++ b/get.php @@ -141,6 +141,11 @@ sendNotFoundPage(); } +// Nothing to do if DB storage is disabled +if (!Mage::helper('core/file_storage_database')->checkDbUsage()) { + sendNotFoundPage(); +} + $localStorage = Mage::getModel('core/file_storage_file'); $remoteStorage = Mage::getModel('core/file_storage_database'); try { From 79cbbc5a6a411591baddd1901edf63f3e86408ce Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Thu, 6 Oct 2022 09:54:52 +0100 Subject: [PATCH 2/3] Always initialize database storage when loaded --- app/code/core/Mage/Core/Model/File/Storage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/core/Mage/Core/Model/File/Storage.php b/app/code/core/Mage/Core/Model/File/Storage.php index da4f63f0603..07a0b3813b0 100644 --- a/app/code/core/Mage/Core/Model/File/Storage.php +++ b/app/code/core/Mage/Core/Model/File/Storage.php @@ -105,6 +105,9 @@ public function getStorageModel($storage = null, $params = []) case self::STORAGE_MEDIA_DATABASE: $connection = $params['connection'] ?? null; $model = Mage::getModel('core/file_storage_database', ['connection' => $connection]); + // Always initialize database storage to ensure the table exists + // see: https://github.com/OpenMage/magento-lts/pull/2627 + $params['init'] = true; break; default: return false; From 6682ad19d6c5b5cce4e1df7b840adf1e2882dacb Mon Sep 17 00:00:00 2001 From: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com> Date: Thu, 6 Oct 2022 20:44:32 +0100 Subject: [PATCH 3/3] Revert "Always initialize database storage when loaded" This reverts commit 79cbbc5a6a411591baddd1901edf63f3e86408ce. --- app/code/core/Mage/Core/Model/File/Storage.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/code/core/Mage/Core/Model/File/Storage.php b/app/code/core/Mage/Core/Model/File/Storage.php index 07a0b3813b0..da4f63f0603 100644 --- a/app/code/core/Mage/Core/Model/File/Storage.php +++ b/app/code/core/Mage/Core/Model/File/Storage.php @@ -105,9 +105,6 @@ public function getStorageModel($storage = null, $params = []) case self::STORAGE_MEDIA_DATABASE: $connection = $params['connection'] ?? null; $model = Mage::getModel('core/file_storage_database', ['connection' => $connection]); - // Always initialize database storage to ensure the table exists - // see: https://github.com/OpenMage/magento-lts/pull/2627 - $params['init'] = true; break; default: return false;