From ee2f5663c46a3114f7053f32f15399b31633fe8c Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 6 Dec 2017 06:41:47 -0700 Subject: [PATCH 1/3] Revert "Fixed issue #1742 where the creation of GPM object tried to connect to Remote repositories even if only Local package was needed (#1746)" This reverts commit 2cc34151dfc12e28b750a01a0997b37a2d33e120. --- system/src/Grav/Common/GPM/GPM.php | 38 ++++------------------- tests/unit/Grav/Common/GPM/GPMTest.php | 43 -------------------------- 2 files changed, 6 insertions(+), 75 deletions(-) diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index 2fc832c54..fd5af4849 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -17,9 +17,6 @@ use Symfony\Component\Yaml\Yaml; class GPM extends Iterator { - /** @var callable */ - private $callback; - /** * Local installed Packages * @var Local\Packages @@ -32,9 +29,6 @@ class GPM extends Iterator */ private $repository; - /** @var bool */ - private $shouldRefresh; - /** * @var Remote\GravCore */ @@ -53,33 +47,18 @@ class GPM extends Iterator ]; /** - * Loads Remote Packages available - */ - private function retrieveRemoteRepository() - { - if (!$this->repository) { - $this->repository = new Remote\Packages($this->shouldRefresh, $this->callback); - } - } - - /** - * Creates a new GPM instance with Local packages available + * Creates a new GPM instance with Local and Remote packages available * @param boolean $refresh Applies to Remote Packages only and forces a refetch of data * @param callable $callback Either a function or callback in array notation */ public function __construct($refresh = false, $callback = null) { $this->installed = new Local\Packages(); - $this->shouldRefresh = $refresh; - $this->callback = $callback; - } - - /** - * Loads Remote Grav package available - */ - public function loadRemoteGrav() - { - $this->grav = new Remote\GravCore($this->refresh, $this->callback); + try { + $this->repository = new Remote\Packages($refresh, $callback); + $this->grav = new Remote\GravCore($refresh, $callback); + } catch (\Exception $e) { + } } /** @@ -289,7 +268,6 @@ class GPM extends Iterator */ public function getLatestVersionOfPackage($package_name) { - $this->retrieveRemoteRepository(); $repository = $this->repository['plugins']; if (isset($repository[$package_name])) { return $repository[$package_name]->available ?: $repository[$package_name]->version; @@ -332,7 +310,6 @@ class GPM extends Iterator public function getUpdatableThemes() { $items = []; - $this->retrieveRemoteRepository(); $repository = $this->repository['themes']; // local cache to speed things up @@ -380,7 +357,6 @@ class GPM extends Iterator */ public function getReleaseType($package_name) { - $this->retrieveRemoteRepository(); $repository = $this->repository['plugins']; if (isset($repository[$package_name])) { return $repository[$package_name]->release_type; @@ -429,7 +405,6 @@ class GPM extends Iterator */ public function getRepositoryPlugin($slug) { - $this->retrieveRemoteRepository(); return @$this->repository['plugins'][$slug]; } @@ -468,7 +443,6 @@ class GPM extends Iterator */ public function getRepository() { - $this->retrieveRemoteRepository(); return $this->repository; } diff --git a/tests/unit/Grav/Common/GPM/GPMTest.php b/tests/unit/Grav/Common/GPM/GPMTest.php index b254b2d4e..aba4a8cf2 100644 --- a/tests/unit/Grav/Common/GPM/GPMTest.php +++ b/tests/unit/Grav/Common/GPM/GPMTest.php @@ -320,47 +320,4 @@ class GpmTest extends \Codeception\TestCase\Test $this->assertSame(null, $this->gpm->calculateVersionNumberFromDependencyVersion('*')); $this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('2.0.2')); } - - public function testRemoteRepositoryIsEmptyAfterConstruct() - { - $gpm = new GPM(); - $reflection = new \ReflectionClass(get_class($gpm)); - $repository = $reflection->getProperty('repository'); - $repository->setAccessible(true); - - $this->assertSame(null, $repository->getValue($gpm)); - } - - public function testLocalRepositoryIsNotEmptyAfterConstruct() - { - $gpm = new GPM(); - $reflection = new \ReflectionClass(get_class($gpm)); - $repository = $reflection->getProperty('installed'); - $repository->setAccessible(true); - - $this->assertInstanceOf( '\Grav\Common\GPM\Local\Packages', $repository->getValue($gpm)); - } - - public function testGetRepository() - { - $this->assertInstanceOf('\Grav\Common\GPM\Remote\Packages', $this->gpm->getRepository()); - } - - public function testLatestVersionOfPackage() - { - $gpm = new GPM(); - $this->assertNotNull($gpm->getLatestVersionOfPackage('admin')); - } - - public function testReleaseType() - { - $gpm = new GPM(); - $this->assertNotNull($gpm->getReleaseType('admin')); - } - - public function testGetRepositoryPlugin() - { - $gpm = new GPM(); - $this->assertNotNull($gpm->getRepositoryPlugin('admin')); - } } From e9f493096b8169d84add74733a7b6eb8aa3a36cf Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 6 Dec 2017 06:43:03 -0700 Subject: [PATCH 2/3] Updated changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0509eff74..9bd06a2be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v1.3.10 +## 12/06/2017 + +1. [](#bugfix) + * Reverted GPM Local pull request as it broken admin [#1742](https://github.com/getgrav/grav/issues/1742) + +1. [](#new) + # v1.3.9 ## 12/05/2017 From 671e0d47ea1d0dcfd55cd1b7e2a718032a22fce8 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 6 Dec 2017 06:43:28 -0700 Subject: [PATCH 3/3] Prepare for release --- system/defines.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/defines.php b/system/defines.php index 12a949ed3..1892be1a9 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.3.9'); +define('GRAV_VERSION', '1.3.10'); //define('GRAV_TESTING', true); define('DS', '/');