Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Extensions check #12

Open
evehne opened this issue Nov 24, 2017 · 1 comment
Open

PHP Extensions check #12

evehne opened this issue Nov 24, 2017 · 1 comment

Comments

@evehne
Copy link

evehne commented Nov 24, 2017

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 */
@evehne evehne changed the title PHP Extention check PHP Extensions check Nov 24, 2017
@rhukster
Copy link
Member

I’ll look to do something like this in 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants