Print an error if mbstring extension is missing
authorJean-Michel Vourgère <nirgal@debian.org>
Sun, 20 Oct 2019 10:42:24 +0000 (12:42 +0200)
committerJean-Michel Vourgère <nirgal@debian.org>
Sun, 20 Oct 2019 10:42:24 +0000 (12:42 +0200)
Generic missing extension messages

lang/english.php
libraries/lib.inc.php

index c232a7524708777e0f30c400fae0eed114d08391..9414113d35371a141a62f63c295e59050ff261d0 100644 (file)
        $lang['strnoframes'] = 'This application works best with a frames-enabled browser, but can be used without frames by following the link below.';
        $lang['strnoframeslink'] = 'Use without frames';
        $lang['strbadconfig'] = 'Your config.inc.php is out of date. You will need to regenerate it from the new config.inc.php-dist.';
-       $lang['strnotloaded'] = 'Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option.';
+       $lang['strlibnotfound'] = 'Your PHP installation does not support the %s module. You will need to install, enable, or compile it to use phpPgAdmin.';
+       $lang['strlibnotfound_plural'] = 'Your PHP installation does not support the %s modules. You will need to install, enable, or compile them to use phpPgAdmin.';
        $lang['strpostgresqlversionnotsupported'] = 'Version of PostgreSQL not supported. Please upgrade to version %s or later.';
        $lang['strbadschema'] = 'Invalid schema specified.';
        $lang['strbadencoding'] = 'Failed to set client encoding in database.';
index 4494680da8c0666850251483da1ded2c91ef2bed..80c62a107ff5d1cd570d601adc260b3477c1ac17 100644 (file)
                exit;
        }
 
-       // Check database support is properly compiled in
-       if (!function_exists('pg_connect')) {
-               echo $lang['strnotloaded'];
+       // Check php libraries
+       $php_libraries_requirements = [
+               // required_function => name_of_the_php_library
+               'pg_connect' => 'pgsql',
+               'mb_strlen' => 'mbstring'];
+       $missing_libraries = [];
+       foreach($php_libraries_requirements as $funcname => $lib)
+               if (!function_exists($funcname))
+                       $missing_libraries[] = $lib;
+       if ($missing_libraries) {
+               $missing_list = implode(', ', $missing_libraries);
+               $error_missing_template_string = count($missing_libraries) <= 1 ? $lang['strlibnotfound'] : $lang['strlibnotfound_plural'];
+               printf($error_missing_template_string, $missing_list);
                exit;
        }