From 13ed181f80c4bb7f0cb48ed0ea33ea07e2de222a Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 14 Apr 2021 15:59:34 +0300 Subject: [PATCH 1/4] Fixed a check for loading problem classes [#32] --- CHANGELOG.md | 6 ++++++ classes/Problems/Base/ProblemChecker.php | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0885c4f..83f8ae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v2.1.1 +## mm/dd/2021 + +1. [](#bugfix) + * Fixed a check for loading problem classes [#32](https://github.com/getgrav/grav-plugin-problems/issues/32) + # v2.1.0 ## 04/13/2021 diff --git a/classes/Problems/Base/ProblemChecker.php b/classes/Problems/Base/ProblemChecker.php index d869371..9650c10 100644 --- a/classes/Problems/Base/ProblemChecker.php +++ b/classes/Problems/Base/ProblemChecker.php @@ -84,14 +84,17 @@ public function check($problems_dir = null): bool $problems = []; $problems_found = false; - foreach (new \DirectoryIterator($problems_dir) as $file) { - if ($file->isDot() || $file->isDir()) { + $iterator = new \DirectoryIterator($problems_dir); + foreach ($iterator as $file) { + if (!$file->isFile() || $file->getExtension() !== 'php') { continue; } $classname = 'Grav\\Plugin\\Problems\\' . $file->getBasename('.php'); - /** @var Problem $problem */ - $problem = new $classname(); - $problems[$problem->getId()] = $problem; + if (class_exists($classname)) { + /** @var Problem $problem */ + $problem = new $classname(); + $problems[$problem->getId()] = $problem; + } } // Fire event to allow other plugins to add problems From 56a59890c6566f76461fda17e241282a1698b949 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 14 Apr 2021 16:12:43 +0300 Subject: [PATCH 2/4] Regression: folders check fails in Windows [#31] --- CHANGELOG.md | 1 + classes/Problems/EssentialFolders.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83f8ae1..c1f9f73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#bugfix) * Fixed a check for loading problem classes [#32](https://github.com/getgrav/grav-plugin-problems/issues/32) + * Regression: folders check fails in Windows [#31](https://github.com/getgrav/grav-plugin-problems/issues/31) # v2.1.0 ## 04/13/2021 diff --git a/classes/Problems/EssentialFolders.php b/classes/Problems/EssentialFolders.php index 70c203f..6516e60 100644 --- a/classes/Problems/EssentialFolders.php +++ b/classes/Problems/EssentialFolders.php @@ -50,7 +50,7 @@ public function process() $file_success = []; foreach ($essential_folders as $file => $check_writable) { - $file_path = (!str_starts_with($file, '/') ? GRAV_ROOT . '/' : '') . $file; + $file_path = (preg_match('`^(/|[a-z]:[\\\/])`ui', $file) ? GRAV_ROOT . '/' : '') . $file; if (!is_dir($file_path)) { $file_errors[$file_path] = 'does not exist'; From bd8ced2ea4031b7c06f88619c9b51503ae402e44 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 14 Apr 2021 16:44:34 +0300 Subject: [PATCH 3/4] Missing negation (typo) [#31] --- classes/Problems/EssentialFolders.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Problems/EssentialFolders.php b/classes/Problems/EssentialFolders.php index 6516e60..6491fea 100644 --- a/classes/Problems/EssentialFolders.php +++ b/classes/Problems/EssentialFolders.php @@ -50,7 +50,7 @@ public function process() $file_success = []; foreach ($essential_folders as $file => $check_writable) { - $file_path = (preg_match('`^(/|[a-z]:[\\\/])`ui', $file) ? GRAV_ROOT . '/' : '') . $file; + $file_path = (!preg_match('`^(/|[a-z]:[\\\/])`ui', $file) ? GRAV_ROOT . '/' : '') . $file; if (!is_dir($file_path)) { $file_errors[$file_path] = 'does not exist'; From 9a127b46ccc21a5ec6336ff37380b4c75ff09679 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 14 Apr 2021 17:23:46 -0600 Subject: [PATCH 4/4] prepare for release --- CHANGELOG.md | 2 +- blueprints.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f9f73..4380dc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v2.1.1 -## mm/dd/2021 +## 04/14/2021 1. [](#bugfix) * Fixed a check for loading problem classes [#32](https://github.com/getgrav/grav-plugin-problems/issues/32) diff --git a/blueprints.yaml b/blueprints.yaml index 98fde54..1456dfb 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Problems slug: problems type: plugin -version: 2.1.0 +version: 2.1.1 description: Detects and reports problems found in the site. icon: exclamation-circle author: