From ee37650b3576d2ff09fefbbb08b59ca2d10fa2b5 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Mon, 4 Apr 2016 10:25:00 +0200 Subject: [PATCH] If a blueprint has no version specified, it's not a GPM package, do not try to update it (CLI/Admin) --- system/src/Grav/Common/GPM/GPM.php | 4 ++-- .../src/Grav/Console/Gpm/VersionCommand.php | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index a71f82884..c4577547f 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -194,7 +194,7 @@ class GPM extends Iterator } foreach ($this->installed['plugins'] as $slug => $plugin) { - if (!isset($repository[$slug]) || $plugin->symlink) { + if (!isset($repository[$slug]) || $plugin->symlink || !$plugin->version || $plugin->gpm === false) { continue; } @@ -272,7 +272,7 @@ class GPM extends Iterator } foreach ($this->installed['themes'] as $slug => $plugin) { - if (!isset($repository[$slug]) || $plugin->symlink) { + if (!isset($repository[$slug]) || $plugin->symlink || !$plugin->version || $plugin->gpm === false) { continue; } diff --git a/system/src/Grav/Console/Gpm/VersionCommand.php b/system/src/Grav/Console/Gpm/VersionCommand.php index 4b64586d0..23d495e6e 100644 --- a/system/src/Grav/Console/Gpm/VersionCommand.php +++ b/system/src/Grav/Console/Gpm/VersionCommand.php @@ -6,6 +6,7 @@ use Grav\Common\GPM\Upgrader; use Grav\Console\ConsoleCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Yaml\Yaml; /** * Class VersionCommand @@ -70,10 +71,26 @@ class VersionCommand extends ConsoleCommand } } else { + // get currently installed version + $locator = \Grav\Common\Grav::instance()['locator']; + $blueprints_path = $locator->findResource('plugins://' . $package . DS . 'blueprints.yaml'); + if (!file_exists($blueprints_path)) { // theme? + $blueprints_path = $locator->findResource('themes://' . $package . DS . 'blueprints.yaml'); + if (!file_exists($blueprints_path)) { + continue; + } + } + + $package_yaml = Yaml::parse(file_get_contents($blueprints_path)); + $currentlyInstalledVersion = $package_yaml['version']; + + if (!$currentlyInstalledVersion) { + continue; + } + $installed = $this->gpm->findPackage($package); if ($installed) { $name = $installed->name; - $version = $installed->version; if ($this->gpm->isUpdatable($package)) { $updatable = ' [updatable: v' . $installed->available . ']'; @@ -84,7 +101,7 @@ class VersionCommand extends ConsoleCommand $updatable = $updatable ?: ''; if ($installed || $package == 'grav') { - $this->output->writeln('You are running ' . $name . ' v' . $version . '' . $updatable); + $this->output->writeln('You are running ' . $name . ' v' . $currentlyInstalledVersion . '' . $updatable); } else { $this->output->writeln('Package ' . $package . ' not found'); }