Skip to content

Commit

Permalink
Fix compatibility issue with October 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ChVuagniaux committed Feb 27, 2024
1 parent 60675f2 commit 43346f9
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
1 change: 1 addition & 0 deletions classes/ComposerUpdateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Artisan;
use Exception;
use Illuminate\Support\Arr;
use System\Classes\UpdateManager;

class ComposerUpdateManager
{
Expand Down
6 changes: 3 additions & 3 deletions classes/OctoberUpdateServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@

class OctoberUpdateServer
{
/** @var UpdateManager */
/** @var UpdateManagerOverrideV1 */
private $updateManager;

/** @var ThemeManager|null */
private $themeManager;

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()
{
Expand Down
18 changes: 18 additions & 0 deletions classes/UpdateManagerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace OnePilot\Client\Classes;

use System\Classes\UpdateManager;

class UpdateManagerFactory
{
/**
* @return UpdateManagerOverrideV1|UpdateManager
*/
public static function instance()
{
return class_exists('System')
? UpdateManager::instance()
: UpdateManagerOverrideV1::instance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* to allow plugin updates ( requestServerFile, extractPlugin )
*/
class UpdateManager extends \System\Classes\UpdateManager
class UpdateManagerOverrideV1 extends \System\Classes\UpdateManager
{
/**
* Modifies the Network HTTP object with common attributes.
Expand Down
4 changes: 2 additions & 2 deletions controllers/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Routing\Controller;
use OnePilot\Client\Classes\Response;
use OnePilot\Client\Classes\UpdateManager;
use OnePilot\Client\Classes\UpdateManagerOverrideV1;
use OnePilot\Client\Exceptions\OnePilotException;

class Core extends Controller
Expand All @@ -23,7 +23,7 @@ public function update()
throw new OnePilotException("Core update is currently not supported for October CMS v2", 500);
}

$manager = UpdateManager::instance();
$manager = UpdateManagerOverrideV1::instance();
$updateList = $manager->requestUpdateList(true);

$coreHash = array_get($updateList, 'core.hash');
Expand Down
4 changes: 2 additions & 2 deletions controllers/Extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions controllers/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand Down Expand Up @@ -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', [
Expand Down
4 changes: 2 additions & 2 deletions controllers/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 43346f9

Please sign in to comment.