diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-16 16:33:02 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-16 16:33:02 +0200 |
commit | ba445e85b25f03364b5a3ca69f1ac7ce047fd697 (patch) | |
tree | d0e388a482ce7f48f7027136c9f6ea48d76973f8 | |
parent | 64653223fc8be1501aa96bc63409fbe3592bc794 (diff) | |
parent | 5813cf32dc5fd329a2379295788bbfaf70f09039 (diff) | |
download | nextcloud-server-ba445e85b25f03364b5a3ca69f1ac7ce047fd697.tar.gz nextcloud-server-ba445e85b25f03364b5a3ca69f1ac7ce047fd697.zip |
Merge pull request #11082 from owncloud/deduplicateDependencyCheck
Deduplicate dependency checks
-rwxr-xr-x | lib/private/util.php | 112 |
1 files changed, 42 insertions, 70 deletions
diff --git a/lib/private/util.php b/lib/private/util.php index 79f3eb7b48c..c5483c1654b 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -493,78 +493,57 @@ class OC_Util { ); } + // Contains the dependencies that should be checked against + // classes = class_exists + // functions = function_exists + // defined = defined + // If the dependency is not found the missing module name is shown to the EndUser + $dependencies = array( + 'classes' => array( + 'ZipArchive' => 'zip', + 'DOMDocument' => 'dom', + ), + 'functions' => array( + 'xml_parser_create' => 'libxml', + 'mb_detect_encoding' => 'mb multibyte', + 'ctype_digit' => 'ctype', + 'json_encode' => 'JSON', + 'gd_info' => 'GD', + 'gzencode' => 'zlib', + 'iconv' => 'iconv', + 'simplexml_load_string' => 'SimpleXML' + ), + 'defined' => array( + 'PDO::ATTR_DRIVER_NAME' => 'PDO' + ) + ); + $missingDependencies = array(); $moduleHint = $l->t('Please ask your server administrator to install the module.'); - // check if all required php modules are present - if (!class_exists('ZipArchive')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('zip')), - 'hint' => $moduleHint - ); - $webServerRestart = true; - } - if (!class_exists('DOMDocument')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('dom')), - 'hint' => $moduleHint - ); - $webServerRestart = true; - } - if (!function_exists('xml_parser_create')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('libxml')), - 'hint' => $moduleHint - ); - $webServerRestart = true; - } - if (!function_exists('mb_detect_encoding')) { - $errors[] = array( - 'error' => 'PHP module mb multibyte not installed.', - 'hint' => $moduleHint - ); - $webServerRestart = true; - } - if (!function_exists('ctype_digit')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('ctype')), - 'hint' => $moduleHint - ); - $webServerRestart = true; - } - if (!function_exists('json_encode')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('JSON')), - 'hint' => $moduleHint - ); - $webServerRestart = true; - } - if (!extension_loaded('gd') || !function_exists('gd_info')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('GD')), - 'hint' => $moduleHint - ); - $webServerRestart = true; + + foreach ($dependencies['classes'] as $class => $module) { + if (!class_exists($class)) { + $missingDependencies[] = $module; + } } - if (!function_exists('gzencode')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('zlib')), - 'hint' => $moduleHint - ); - $webServerRestart = true; + foreach ($dependencies['functions'] as $function => $module) { + if (!function_exists($function)) { + $missingDependencies[] = $module; + } } - if (!function_exists('iconv')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('iconv')), - 'hint' => $moduleHint - ); - $webServerRestart = true; + foreach ($dependencies['defined'] as $defined => $module) { + if (!defined($defined)) { + $missingDependencies[] = $module; + } } - if (!function_exists('simplexml_load_string')) { + + foreach($missingDependencies as $missingDependency) { $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('SimpleXML')), + 'error' => $l->t('PHP module %s not installed.', array($missingDependency)), 'hint' => $moduleHint ); $webServerRestart = true; } + if (version_compare(phpversion(), '5.3.3', '<')) { $errors[] = array( 'error' => $l->t('PHP %s or higher is required.', '5.3.3'), @@ -573,13 +552,6 @@ class OC_Util { ); $webServerRestart = true; } - if (!defined('PDO::ATTR_DRIVER_NAME')) { - $errors[] = array( - 'error' => $l->t('PHP module %s not installed.', array('PDO')), - 'hint' => $moduleHint - ); - $webServerRestart = true; - } if (((strtolower(@ini_get('safe_mode')) == 'on') || (strtolower(@ini_get('safe_mode')) == 'yes') || (strtolower(@ini_get('safe_mode')) == 'true') |