mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 15:29:57 +01:00
Fixed GPM errors from blueprints not being logged [#2505]
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* Optimizations for Plugin/Theme loading
|
||||
1. [](#bugfix)
|
||||
* Force question to install demo content in theme update [#2493](https://github.com/getgrav/grav/issues/2493)
|
||||
* Fixed GPM errors from blueprints not being logged [#2505](https://github.com/getgrav/grav/issues/2505)
|
||||
|
||||
# v1.6.9
|
||||
## 05/09/2019
|
||||
|
||||
@@ -39,7 +39,8 @@ class Blueprints
|
||||
public function get($type)
|
||||
{
|
||||
if (!isset($this->instances[$type])) {
|
||||
$this->instances[$type] = $this->loadFile($type);
|
||||
$blueprint = $this->loadFile($type);
|
||||
$this->instances[$type] = $blueprint;
|
||||
}
|
||||
|
||||
return $this->instances[$type];
|
||||
@@ -99,6 +100,15 @@ class Blueprints
|
||||
$blueprint->setContext($this->search);
|
||||
}
|
||||
|
||||
return $blueprint->load()->init();
|
||||
try {
|
||||
$blueprint->load()->init();
|
||||
} catch (\RuntimeException $e) {
|
||||
$log = Grav::instance()['log'];
|
||||
$log->error(sprintf('Blueprint %s cannot be loaded: %s', $name, $e->getMessage()));
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $blueprint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,19 +11,22 @@ namespace Grav\Common\GPM\Common;
|
||||
|
||||
use Grav\Common\Iterator;
|
||||
|
||||
class CachedCollection extends Iterator {
|
||||
|
||||
class CachedCollection extends Iterator
|
||||
{
|
||||
protected static $cache;
|
||||
|
||||
public function __construct($items)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$method = static::class . __METHOD__;
|
||||
|
||||
// local cache to speed things up
|
||||
if (!isset(self::$cache[get_called_class() . __METHOD__])) {
|
||||
self::$cache[get_called_class() . __METHOD__] = $items;
|
||||
if (!isset(self::$cache[$method])) {
|
||||
self::$cache[$method] = $items;
|
||||
}
|
||||
|
||||
foreach (self::$cache[get_called_class() . __METHOD__] as $name => $item) {
|
||||
foreach (self::$cache[$method] as $name => $item) {
|
||||
$this->append([$name => $item]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Grav\Common\GPM\Common;
|
||||
|
||||
use Grav\Common\Data\Data;
|
||||
|
||||
class Package {
|
||||
|
||||
class Package
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
|
||||
@@ -770,7 +770,7 @@ class GPM extends Iterator
|
||||
* @param array $ignore_packages_list
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function checkNoOtherPackageNeedsThisDependencyInALowerVersion(
|
||||
$slug,
|
||||
@@ -793,8 +793,8 @@ class GPM extends Iterator
|
||||
$compatible = $this->checkNextSignificantReleasesAreCompatible($version,
|
||||
$other_dependency_version);
|
||||
if (!$compatible) {
|
||||
if (!in_array($dependent_package, $ignore_packages_list)) {
|
||||
throw new \Exception("Package <cyan>$slug</cyan> is required in an older version by package <cyan>$dependent_package</cyan>. This package needs a newer version, and because of this it cannot be installed. The <cyan>$dependent_package</cyan> package must be updated to use a newer release of <cyan>$slug</cyan>.",
|
||||
if (!in_array($dependent_package, $ignore_packages_list, true)) {
|
||||
throw new \RuntimeException("Package <cyan>$slug</cyan> is required in an older version by package <cyan>$dependent_package</cyan>. This package needs a newer version, and because of this it cannot be installed. The <cyan>$dependent_package</cyan> package must be updated to use a newer release of <cyan>$slug</cyan>.",
|
||||
2);
|
||||
}
|
||||
}
|
||||
@@ -850,10 +850,10 @@ class GPM extends Iterator
|
||||
) {
|
||||
//Needs a Grav update first
|
||||
throw new \RuntimeException("<red>One of the packages require PHP {$dependencies['php']}. Please update PHP to resolve this");
|
||||
} else {
|
||||
unset($dependencies[$dependency_slug]);
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($dependencies[$dependency_slug]);
|
||||
continue;
|
||||
}
|
||||
|
||||
//First, check for Grav dependency. If a dependency requires Grav > the current version, abort and tell.
|
||||
@@ -863,10 +863,10 @@ class GPM extends Iterator
|
||||
) {
|
||||
//Needs a Grav update first
|
||||
throw new \RuntimeException("<red>One of the packages require Grav {$dependencies['grav']}. Please update Grav to the latest release.");
|
||||
} else {
|
||||
unset($dependencies[$dependency_slug]);
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($dependencies[$dependency_slug]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->isPluginInstalled($dependency_slug)) {
|
||||
@@ -1092,6 +1092,7 @@ class GPM extends Iterator
|
||||
if ($this->versionFormatIsEqualOrHigher($version)) {
|
||||
return trim(substr($version, 2));
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
@@ -1104,7 +1105,7 @@ class GPM extends Iterator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function versionFormatIsNextSignificantRelease($version)
|
||||
public function versionFormatIsNextSignificantRelease($version): bool
|
||||
{
|
||||
return strpos($version, '~') === 0;
|
||||
}
|
||||
@@ -1118,7 +1119,7 @@ class GPM extends Iterator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function versionFormatIsEqualOrHigher($version)
|
||||
public function versionFormatIsEqualOrHigher($version): bool
|
||||
{
|
||||
return strpos($version, '>=') === 0;
|
||||
}
|
||||
@@ -1136,7 +1137,7 @@ class GPM extends Iterator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkNextSignificantReleasesAreCompatible($version1, $version2)
|
||||
public function checkNextSignificantReleasesAreCompatible($version1, $version2): bool
|
||||
{
|
||||
$version1array = explode('.', $version1);
|
||||
$version2array = explode('.', $version2);
|
||||
|
||||
@@ -16,6 +16,7 @@ abstract class AbstractPackageCollection extends BaseCollection
|
||||
public function __construct($items)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
foreach ($items as $name => $data) {
|
||||
$data->set('slug', $name);
|
||||
$this->items[$name] = new Package($data, $this->type);
|
||||
|
||||
@@ -25,6 +25,7 @@ class Plugins extends AbstractPackageCollection
|
||||
{
|
||||
/** @var \Grav\Common\Plugins $plugins */
|
||||
$plugins = Grav::instance()['plugins'];
|
||||
|
||||
parent::__construct($plugins->all());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class AbstractPackageCollection extends BaseCollection
|
||||
{
|
||||
parent::__construct();
|
||||
if ($repository === null) {
|
||||
throw new \RuntimeException("A repository is required to indicate the origin of the remote collection");
|
||||
throw new \RuntimeException('A repository is required to indicate the origin of the remote collection');
|
||||
}
|
||||
|
||||
$channel = Grav::instance()['config']->get('system.gpm.releases', 'stable');
|
||||
|
||||
@@ -37,9 +37,9 @@ class GravCore extends AbstractPackageCollection
|
||||
$this->fetch($refresh, $callback);
|
||||
|
||||
$this->data = json_decode($this->raw, true);
|
||||
$this->version = isset($this->data['version']) ? $this->data['version'] : '-';
|
||||
$this->date = isset($this->data['date']) ? $this->data['date'] : '-';
|
||||
$this->min_php = isset($this->data['min_php']) ? $this->data['min_php'] : null;
|
||||
$this->version = $this->data['version'] ?? '-';
|
||||
$this->date = $this->data['date'] ?? '-';
|
||||
$this->min_php = $this->data['min_php'] ?? null;
|
||||
|
||||
if (isset($this->data['assets'])) {
|
||||
foreach ((array)$this->data['assets'] as $slug => $data) {
|
||||
|
||||
@@ -133,12 +133,25 @@ class Plugins extends Iterator
|
||||
*/
|
||||
public static function all()
|
||||
{
|
||||
$plugins = Grav::instance()['plugins'];
|
||||
$grav = Grav::instance();
|
||||
$plugins = $grav['plugins'];
|
||||
$list = [];
|
||||
|
||||
foreach ($plugins as $instance) {
|
||||
$name = $instance->name;
|
||||
$result = self::get($name);
|
||||
|
||||
try {
|
||||
$result = self::get($name);
|
||||
} catch (\Exception $e) {
|
||||
$exception = new \RuntimeException(sprintf('Plugin %s: %s', $name, $e->getMessage()), $e->getCode(), $e);
|
||||
|
||||
/** @var Debugger $debugger */
|
||||
$debugger = $grav['debugger'];
|
||||
$debugger->addMessage("Plugin {$name} cannot be loaded, please check Exceptions tab", 'error');
|
||||
$debugger->addException($exception);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$list[$name] = $result;
|
||||
|
||||
@@ -100,7 +100,19 @@ class Themes extends Iterator
|
||||
}
|
||||
|
||||
$theme = $directory->getFilename();
|
||||
$result = $this->get($theme);
|
||||
|
||||
try {
|
||||
$result = $this->get($theme);
|
||||
} catch (\Exception $e) {
|
||||
$exception = new \RuntimeException(sprintf('Theme %s: %s', $theme, $e->getMessage()), $e->getCode(), $e);
|
||||
|
||||
/** @var Debugger $debugger */
|
||||
$debugger = $this->grav['debugger'];
|
||||
$debugger->addMessage("Theme {$theme} cannot be loaded, please check Exceptions tab", 'error');
|
||||
$debugger->addException($exception);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$list[$theme] = $result;
|
||||
|
||||
Reference in New Issue
Block a user