diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index fa1c8081e..c6088e42e 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -323,13 +323,20 @@ class GPM extends Iterator return $found; } - foreach ($this->getRepositoryThemes() as $slug => $theme) { + $themes = $this->getRepositoryThemes(); + $plugins = $this->getRepositoryPlugins(); + + if (!$themes && !$plugins) { + throw new \RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable"); + } + + if ($themes) foreach ($themes as $slug => $theme) { if ($search == $slug || $search == $theme->name) { return $theme; } } - foreach ($this->getRepositoryPlugins() as $slug => $plugin) { + if ($plugins) foreach ($plugins as $slug => $plugin) { if ($search == $slug || $search == $plugin->name) { return $plugin; }