From 43346f9986f40d5a5b4efd548735973719c92950 Mon Sep 17 00:00:00 2001 From: Christophe Vuagniaux Date: Tue, 27 Feb 2024 12:01:25 +0100 Subject: [PATCH] Fix compatibility issue with October 3.6 --- classes/ComposerUpdateManager.php | 1 + classes/OctoberUpdateServer.php | 6 +++--- classes/UpdateManagerFactory.php | 18 ++++++++++++++++++ ...Manager.php => UpdateManagerOverrideV1.php} | 2 +- controllers/Core.php | 4 ++-- controllers/Extensions.php | 4 ++-- controllers/Plugins.php | 7 ++++--- controllers/Validate.php | 4 ++-- updates/version.yaml | 2 ++ 9 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 classes/UpdateManagerFactory.php rename classes/{UpdateManager.php => UpdateManagerOverrideV1.php} (98%) diff --git a/classes/ComposerUpdateManager.php b/classes/ComposerUpdateManager.php index 760c01f..b7b8520 100644 --- a/classes/ComposerUpdateManager.php +++ b/classes/ComposerUpdateManager.php @@ -6,6 +6,7 @@ use Artisan; use Exception; use Illuminate\Support\Arr; +use System\Classes\UpdateManager; class ComposerUpdateManager { diff --git a/classes/OctoberUpdateServer.php b/classes/OctoberUpdateServer.php index cb17701..489c8b8 100644 --- a/classes/OctoberUpdateServer.php +++ b/classes/OctoberUpdateServer.php @@ -9,7 +9,7 @@ class OctoberUpdateServer { - /** @var UpdateManager */ + /** @var UpdateManagerOverrideV1 */ private $updateManager; /** @var ThemeManager|null */ @@ -17,13 +17,13 @@ class OctoberUpdateServer public function __construct() { - $this->updateManager = UpdateManager::instance(); + $this->updateManager = UpdateManagerFactory::instance(); $this->themeManager = class_exists(ThemeManager::class) ? ThemeManager::instance() : null; } /** * @return array - * @see UpdateManager::requestUpdateList + * @see UpdateManagerOverrideV1::requestUpdateList */ public function availableUpdates() { diff --git a/classes/UpdateManagerFactory.php b/classes/UpdateManagerFactory.php new file mode 100644 index 0000000..8e74150 --- /dev/null +++ b/classes/UpdateManagerFactory.php @@ -0,0 +1,18 @@ +requestUpdateList(true); $coreHash = array_get($updateList, 'core.hash'); diff --git a/controllers/Extensions.php b/controllers/Extensions.php index 5ff3344..080a6b2 100644 --- a/controllers/Extensions.php +++ b/controllers/Extensions.php @@ -9,7 +9,7 @@ use October\Rain\Network\Http; use OnePilot\Client\Classes\File; use OnePilot\Client\Classes\Response; -use OnePilot\Client\Classes\UpdateManager; +use OnePilot\Client\Classes\UpdateManagerFactory; use OnePilot\Client\Exceptions\OnePilotException; use Request; use SplFileInfo; @@ -88,7 +88,7 @@ private function installPlugin($file) $pluginClass = PluginManager::instance()->loadPlugin($namespace, $targetPath); // Apply DB updates - $updateManager = UpdateManager::instance(); + $updateManager = UpdateManagerFactory::instance(); $updateManager->updatePlugin($pluginCode); // Get plugin version from the DB diff --git a/controllers/Plugins.php b/controllers/Plugins.php index bdadb67..f904bf1 100644 --- a/controllers/Plugins.php +++ b/controllers/Plugins.php @@ -6,7 +6,8 @@ use Illuminate\Routing\Controller; use Illuminate\Support\Collection; use OnePilot\Client\Classes\Response; -use OnePilot\Client\Classes\UpdateManager; +use OnePilot\Client\Classes\UpdateManagerFactory; +use OnePilot\Client\Classes\UpdateManagerOverrideV1; use OnePilot\Client\Exceptions\OnePilotException; use Request; use System\Models\PluginVersion; @@ -31,7 +32,7 @@ public function update() throw new OnePilotException("Plugin update is currently not supported for October CMS v2", 500); } - $manager = UpdateManager::instance(); + $manager = UpdateManagerOverrideV1::instance(); $pluginDetails = $manager->requestPluginDetails($pluginCode); $code = array_get($pluginDetails, 'code'); @@ -109,7 +110,7 @@ private function formatPluginResponse($plugin, $updates, $pluginsDetails) */ private function getPluginsDetails($plugins) { - $updateManager = UpdateManager::instance(); + $updateManager = UpdateManagerFactory::instance(); try { $productsDetails = $updateManager->requestServerData('plugin/details', [ diff --git a/controllers/Validate.php b/controllers/Validate.php index cb51740..c1d40c3 100644 --- a/controllers/Validate.php +++ b/controllers/Validate.php @@ -9,7 +9,7 @@ use OnePilot\Client\Classes\LogsOverview; use OnePilot\Client\Classes\OctoberUpdateServer; use OnePilot\Client\Classes\Response; -use OnePilot\Client\Classes\UpdateManager; +use OnePilot\Client\Classes\UpdateManagerFactory; use OnePilot\Client\Models\Settings; use System\Models\Parameter; @@ -52,7 +52,7 @@ public function validate() private function core($updates) { - $updateManager = UpdateManager::instance(); + $updateManager = UpdateManagerFactory::instance(); $version = method_exists($updateManager, 'getCurrentVersion') ? $updateManager->getCurrentVersion() // OCMS V2 diff --git a/updates/version.yaml b/updates/version.yaml index e544dc4..839011e 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -28,3 +28,5 @@ - Fix update reporting issue with October 1.0 1.2.2: - Add October v3 support and Read logs from files instead of the DB +1.2.3: + - Fix compatibility issue with October 3.6