Skip to content

Commit aa0045a

Browse files
committed
Merge branch 'release/2.2.0'
2 parents b090e9d + 81308f6 commit aa0045a

File tree

10 files changed

+134
-82
lines changed

10 files changed

+134
-82
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# v2.2.0
2+
## 03/20/2025
3+
4+
1. [](#new)
5+
* Extended php module checks [#38](https://github.com/getgrav/grav-plugin-problems/pull/38)
6+
1. [](#improved)
7+
* Make sure the Essential Folders are listed without extra '/' in front of them
8+
* Updated `http://` links to `https://` across files [#41](https://github.com/getgrav/grav-plugin-problems/pull/41)
9+
* Clarify Apache module detection text [#40](https://github.com/getgrav/grav-plugin-problems/pull/40)
10+
* Ensure essential folder are listed without extra `/` [#39](https://github.com/getgrav/grav-plugin-problems/pull/39)
11+
112
# v2.1.2
213
## 10/22/2024
314

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
![Problems](assets/readme_1.jpg)
66

7-
`Problems` is a [Grav](http://github.com/getgrav/grav) Plugin and allows to detect issues.
7+
`Problems` is a [Grav](https://github.com/getgrav/grav) Plugin and allows to detect issues.
88

99
This plugin is included in any package distributed that contains Grav. If you decide to clone Grav from GitHub, you will most likely want to install this.
1010

@@ -14,21 +14,21 @@ Installing the Problems plugin can be done in one of two ways. Our GPM (Grav Pac
1414

1515
## GPM Installation (Preferred)
1616

17-
The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type:
17+
The simplest way to install this plugin is via the [Grav Package Manager (GPM)](https://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type:
1818

1919
bin/gpm install problems
2020

2121
This will install the Problems plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/problems`.
2222

2323
## Manual Installation
2424

25-
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `problems`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-problems) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
25+
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `problems`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-problems) or via [GetGrav.org](https://getgrav.org/downloads/plugins#extras).
2626

2727
You should now have all the plugin files under
2828

2929
/your/site/grav/user/plugins/problems
3030

31-
> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate.
31+
> NOTE: This plugin is a modular component for Grav which requires [Grav](https://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate.
3232
3333
# Usage
3434

blueprints.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Problems
22
slug: problems
33
type: plugin
4-
version: 2.1.2
4+
version: 2.2.0
55
description: Detects and reports problems found in the site.
66
icon: exclamation-circle
77
author:
88
name: Team Grav
99
email: devs@getgrav.org
10-
url: http://getgrav.org
10+
url: https://getgrav.org
1111
homepage: https://github.com/getgrav/grav-plugin-problems
1212
keywords: problems, plugin, detector, assistant, required
1313
bugs: https://github.com/getgrav/grav-plugin-problems/issues

classes/Problems/Apache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function process()
5252

5353
$this->details = ['errors' => $apache_errors, 'success' => $apache_success];
5454
} else {
55-
$this->msg = 'Apache not installed, skipping...';
55+
$this->msg = 'Apache is not installed or PHP is not installed as Apache module, skipping...';
5656
}
5757

5858
return $this;

classes/Problems/EssentialFolders.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function process()
5151

5252
foreach ($essential_folders as $file => $check_writable) {
5353
$file_path = (!preg_match('`^(/|[a-z]:[\\\/])`ui', $file) ? GRAV_ROOT . '/' : '') . $file;
54+
$file_path = preg_replace('`^/*`', '/', $file_path);
5455

5556
if (!is_dir($file_path)) {
5657
$file_errors[$file_path] = 'does not exist';

classes/Problems/PHPModules.php

Lines changed: 88 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
*/
1212
class PHPModules extends Problem
1313
{
14+
protected $modules_errors = [];
15+
protected $modules_warning = [];
16+
protected $modules_success = [];
17+
1418
public function __construct()
1519
{
1620
$this->id = 'PHP Modules';
@@ -21,37 +25,57 @@ public function __construct()
2125
$this->help = 'https://learn.getgrav.org/basics/requirements#php-requirements';
2226
}
2327

28+
/**
29+
* @param string $module PHP module name.
30+
* @param bool $required If it is required for grav.
31+
* @param string $module_show_name More common module name to display.
32+
* @return void
33+
*/
34+
protected function check_php_module(string $module, bool $required, string $module_show_name = ''): void{
35+
$msg = 'PHP ';
36+
$msg .= (($module_show_name!=='') ? $module_show_name : $module);
37+
$msg .= ' is %s installed';
38+
if(extension_loaded($module)){
39+
$this->modules_success[$module] = sprintf($msg, 'successfully');
40+
}else if($required){
41+
$this->modules_errors[$module] = sprintf($msg, 'required but not');
42+
}else{
43+
$this->modules_warning[$module] = sprintf($msg, 'recommended but not');
44+
}
45+
}
46+
47+
/**
48+
* @param string $module PHP cache module name.
49+
* @param string $module_show_name More common module name to display.
50+
* @return void
51+
*/
52+
protected function check_cache_module(string $module, string $module_show_name = ''): void{
53+
$msg = 'PHP (optional) Cache ';
54+
$msg .= (($module_show_name!=='') ? $module_show_name : $module);
55+
$msg .= ' is %s installed';
56+
if( extension_loaded($module) ){
57+
$this->modules_success[$module] = sprintf($msg, 'successfully');
58+
} else {
59+
$this->modules_warning[$module] = sprintf($msg, 'not');
60+
}
61+
}
62+
2463
/**
2564
* @return $this
2665
*/
2766
public function process()
2867
{
29-
$modules_errors = [];
30-
$modules_success = [];
31-
3268
// Check for PHP CURL library
33-
$msg = 'PHP Curl (Data Transfer Library) is %s installed';
34-
if (function_exists('curl_version')) {
35-
$modules_success['curl'] = sprintf($msg, 'successfully');
36-
} else {
37-
$modules_errors['curl'] = sprintf($msg, 'required but not');
38-
}
69+
$this->check_php_module('curl', true, 'Curl (Data Transfer Library)');
3970

4071
// Check for PHP Ctype library
41-
$msg = 'PHP Ctype is %s installed';
42-
if (function_exists('ctype_print')) {
43-
$modules_success['ctype'] = sprintf($msg, 'successfully');
44-
} else {
45-
$modules_errors['ctype'] = sprintf($msg, 'required but not');
46-
}
72+
$this->check_php_module('ctype', true, 'Ctype');
4773

4874
// Check for PHP Dom library
49-
$msg = 'PHP DOM is %s installed';
50-
if (class_exists('DOMDocument')) {
51-
$modules_success['dom'] = sprintf($msg, 'successfully');
52-
} else {
53-
$modules_errors['dom'] = sprintf($msg, 'required but not');
54-
}
75+
$this->check_php_module('dom', true, 'DOM');
76+
77+
// Check for PHP fileinfo library
78+
$this->check_php_module('fileinfo', false);
5579

5680
// Check for GD library
5781
$msg = 'PHP GD (Image Manipulation Library) is %s installed';
@@ -76,73 +100,69 @@ public function process()
76100
}
77101

78102
if ($problems_found) {
79-
$msg .= ' but missing ' . $gda_msg;
103+
$this->modules_warning['gd'] = $msg . ' but missing ' . $gda_msg;
80104
}
81105

82-
$modules_success['gd'] = $msg;
106+
$this->modules_success['gd'] = $msg;
83107
} else {
84-
$modules_errors['gd'] = sprintf($msg, 'required but not');
108+
$this->modules_errors['gd'] = sprintf($msg, 'required but not');
85109
}
86110

87111
// Check for PHP MbString library
88-
$msg = 'PHP Mbstring (Multibyte String Library) is %s installed';
89-
if (extension_loaded('mbstring')) {
90-
$modules_success['mbstring'] = sprintf($msg, 'successfully');
91-
} else {
92-
$modules_errors['mbstring'] = sprintf($msg, 'required but not');
93-
}
112+
$this->check_php_module('mbstring', true, 'Mbstring (Multibyte String Library)');
113+
114+
// Check for PHP iconv library
115+
$this->check_php_module('iconv', false);
116+
117+
// Check for PHP intl library
118+
$required = Grav::instance()['config']->get('system.intl_enabled');
119+
$this->check_php_module('intl', $required, 'intl (Internationalization Functions)');
94120

95121
// Check for PHP Open SSL library
96-
$msg = 'PHP OpenSSL (Secure Sockets Library) is %s installed';
97-
if (defined('OPENSSL_VERSION_TEXT') && extension_loaded('openssl')) {
98-
$modules_success['openssl'] = sprintf($msg, 'successfully');
99-
} else {
100-
$modules_errors['openssl'] = sprintf($msg, 'required but not');
101-
}
122+
$this->check_php_module('openssl', true, 'OpenSSL (Secure Sockets Library)');
102123

103-
// Check for PHP XML library
104-
$msg = 'PHP JSON Library is %s installed';
105-
if (extension_loaded('json')) {
106-
$modules_success['json'] = sprintf($msg, 'successfully');
107-
} else {
108-
$modules_errors['json'] = sprintf($msg, 'required but not');
109-
}
124+
// Check for PHP JSON library
125+
$this->check_php_module('json', true, 'JSON Library');
110126

111-
// Check for PHP XML library
112-
$msg = 'PHP XML Library is %s installed';
113-
if (extension_loaded('xml')) {
114-
$modules_success['xml'] = sprintf($msg, 'successfully');
115-
} else {
116-
$modules_errors['xml'] = sprintf($msg, 'required but not');
117-
}
127+
// Check for PHP libraries for symfony
128+
$this->check_php_module('PCRE', true, 'PCRE (Perl Compatible Regular Expressions)');
129+
$this->check_php_module('session', true);
130+
131+
// Check for PHP XML libraries
132+
$this->check_php_module('libxml', true, 'libxml Library');
133+
$this->check_php_module('simplexml', true, 'SimpleXML Library');
134+
$this->check_php_module('xml', true, 'XML Library');
135+
136+
// Check for PHP yaml library
137+
$this->check_php_module('yaml', false);
118138

119139
// Check for PHP Zip library
120-
$msg = 'PHP Zip extension is %s installed';
121-
if (extension_loaded('zip')) {
122-
$modules_success['zip'] = sprintf($msg, 'successfully');
123-
} else {
124-
$modules_errors['zip'] = sprintf($msg, 'required but not');
125-
}
140+
$this->check_php_module('zip', true, 'Zip extension');
126141

127142
// Check Exif if enabled
128-
if (Grav::instance()['config']->get('system.media.auto_metadata_exif')) {
129-
$msg = 'PHP Exif (Exchangeable Image File Format) is %s installed';
130-
if (extension_loaded('exif')) {
131-
$modules_success['exif'] = sprintf($msg, 'successfully');
132-
} else {
133-
$modules_errors['exif'] = sprintf($msg, 'required but not');
134-
}
135-
}
136-
137-
if (empty($modules_errors)) {
143+
$required = Grav::instance()['config']->get('system.media.auto_metadata_exif');
144+
$this->check_php_module('exif', $required, 'Exif (Exchangeable Image File Format)');
145+
146+
// Check cache modules
147+
$this->check_cache_module('apcu', 'APC User Cache');
148+
$this->check_cache_module('memcache');
149+
$this->check_cache_module('memcached');
150+
$this->check_cache_module('redis');
151+
$this->check_cache_module('wincache', 'WinCache');
152+
$this->check_cache_module('zend opcache', 'Zend OPcache');
153+
154+
if (empty($this->modules_errors)) {
138155
$this->status = true;
139-
$this->msg = 'All modules look good!';
156+
$this->msg = 'All required modules look good!';
157+
if(!empty($this->modules_warning)) {
158+
$this->msg .= ' Some recommendations do exist.';
159+
}
140160
} else {
141161
$this->status = false;
142162
$this->msg = 'There were problems with required modules:';
143163
}
144164

145-
$this->details = ['errors' => $modules_errors, 'success' => $modules_success];
165+
$this->details = ['errors' => $this->modules_errors, 'warning' => $this->modules_warning, 'success' => $this->modules_success];
146166

147167
return $this;
148168
}

cli/CheckCommand.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ protected function serve(): int
6969
if (is_array($details)) {
7070

7171
$errors_row = [];
72+
$warning_row = [];
7273
$success_row = [];
7374

7475
if (isset($details['errors'])) {
@@ -77,6 +78,12 @@ protected function serve(): int
7778
}
7879
}
7980

81+
if (isset($details['warning'])) {
82+
foreach ($details['warning'] as $key => $value) {
83+
$warning_row[] = "<yellow>⚑</yellow> {$key}{$value}";
84+
}
85+
}
86+
8087
if (isset($details['success'])) {
8188
foreach ($details['success'] as $key => $value) {
8289
$success_row[] = "<green>✔</green> {$key}{$value}";
@@ -86,6 +93,10 @@ protected function serve(): int
8693
foreach($errors_row as $e_row) {
8794
$rows[] = ['', new TableCell($e_row, array('colspan' => 3)), ];
8895
}
96+
97+
foreach($warning_row as $e_row) {
98+
$rows[] = ['', new TableCell($e_row, array('colspan' => 3)), ];
99+
}
89100

90101
foreach($success_row as $e_row) {
91102
$rows[] = ['', new TableCell($e_row, array('colspan' => 3)), ];

templates/problems.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{% include 'reports/problems-report.html.twig' %}
2525

2626
<p class="footer text-center">
27-
<a href="http://getgrav.org">Grav</a> was <img src="{{ problems_url }}/assets/code-3.svg" /> with <img class="love" src="{{ problems_url }}/assets/heart.svg" /> by <a href="https://trilby.media">Trilby Media</a>.
27+
<a href="https://getgrav.org">Grav</a> was <img src="{{ problems_url }}/assets/code-3.svg" /> with <img class="love" src="{{ problems_url }}/assets/heart.svg" /> by <a href="https://trilby.media">Trilby Media</a>.
2828
</p>
2929
</div>
3030

templates/reports/problems-report.html.twig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
</li>
1919
{% endfor %}
2020

21+
{% for key,value in problem.details.warning %}
22+
<li class="menu-item">
23+
<div class="menu-badge">
24+
<label class="label label-warning"><i class="icon icon-flag"></i></label>
25+
</div>
26+
<span class=""><code>{{ key }}</code> - {{ value|raw }}</span>
27+
</li>
28+
{% endfor %}
29+
2130
{% for key,value in problem.details.success %}
2231
<li class="menu-item">
2332
<div class="menu-badge">

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,9 @@ inherits@2, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3:
13661366
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
13671367

13681368
ini@^1.3.4:
1369-
version "1.3.5"
1370-
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
1371-
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
1369+
version "1.3.7"
1370+
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84"
1371+
integrity sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==
13721372

13731373
interpret@^1.0.0:
13741374
version "1.2.0"
@@ -3234,9 +3234,9 @@ wrappy@1:
32343234
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
32353235

32363236
y18n@^4.0.0:
3237-
version "4.0.0"
3238-
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
3239-
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
3237+
version "4.0.1"
3238+
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
3239+
integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
32403240

32413241
yallist@^2.1.2:
32423242
version "2.1.2"

0 commit comments

Comments
 (0)