getgrav / getgrav/grav-plugin-problems

PHP Extensions check

Open
#12 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
SCSS
Stars
10
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Adding private function before `ProblemsPlugin.problemsChecker()` :

```
private function safe_extension_loaded($aExtName)
{
if(!isset($this->__php_extensions)) $this->__php_extensions = get_loaded_extensions();
return extension_loaded($aExtName) || in_array($aExtName, $this->__php_extensions);
}
```

simplify and reduce the function `ProblemsPlugin.problemsChecker()` :
after `//Check PHP version (...) $this->results['php'] (...)`
before `//Check for essential files & perms`
replace all php extensions tests by :
```
/* BEGIN :: CHECK PHP EXTENSIONS */
$php_extensions = [
[ 'n'=>'gd', 't'=>'GD (Image Manipulation Library)', 'l'=>$this->safe_extension_loaded('gd') ],
[ 'n'=>'curl', 't'=>'cURL (Data Transfer Library)', 'l'=>$this->safe_extension_loaded('curl') ],
[ 'n'=>'openssl', 't'=>'openSSL (Secure Socket Library)', 'l'=>$this->safe_extension_loaded('openssl') ],
[ 'n'=>'xml', 't'=>'XML (eXtensible Markup Language Library)', 'l'=>$this->safe_extension_loaded('xml') ],
[ 'n'=>'mbstring', 't'=>'MBString (Multibyte String Library)', 'l'=>$this->safe_extension_loaded('mbstring') ],
[ 'n'=>'exif', 't'=>'Exif (Exchangeable Image File Format)', 'l'=>$this->safe_extension_loaded('exif') || !$this->grav['config']->get('system.media.auto_metadata_exif') ],
[ 'n'=>'zip', 't'=>'Zip (Data Compression Library)', 'l'=>$this->safe_extension_loaded('zip') ],
];
foreach( $php_extensions as $e )
{
$problems_found |= !$e['l'];
$this->results[ $e['n'] ] = [ ($e['l']?'success':'error') => sprintf('PHP %s is %s', $e['t'], $e['l']?'installed':'not installed') ];
}
/* END :: CHECK PHP EXTENSIONS */
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in the file containing ProblemsPlugin.problemsChecker() and inspect the existing PHP version and extension checks. Add the safe extension lookup described in the issue, then replace the extension checks with the listed collection and loop. Done means the existing extension result entries and problems-found flag still report each required extension correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.