Skip to content

PHP Extensions check #12

Description

@evehne

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 */

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions