Fix detection of php.ini file
authorJamie Cameron <jcameron@webmin.com>
Fri, 8 Jan 2010 21:06:15 +0000 (13:06 -0800)
committerJamie Cameron <jcameron@webmin.com>
Fri, 8 Jan 2010 21:06:15 +0000 (13:06 -0800)
phpini/install_check.pl
phpini/phpini-lib.pl

index f0f77f0..e20df04 100755 (executable)
@@ -8,7 +8,7 @@ do 'phpini-lib.pl';
 # For mode 0, returns 1 if installed, 0 if not
 sub is_installed
 {
-return -r $config{'php_ini'} ||
+return &get_default_php_ini() ||
        &has_command("php") ||
        &has_command("php4") ||
        &has_command("php5") ||
index 29601bf..6143b74 100755 (executable)
@@ -10,7 +10,7 @@ use WebminCore;
 sub get_config
 {
 local ($file) = @_;
-$file ||= $config{'php_ini'};
+$file ||= &get_default_php_ini();
 if (!defined($get_config_cache{$file})) {
        local @rv = ( );
        local $lnum = 0;
@@ -147,8 +147,19 @@ return &indexof($file, map { $_->[0] } &list_php_configs()) >= 0 ||
        $access{'anyfile'};
 }
 
+# get_default_php_ini()
+# Returns the first php.ini that exists
+sub get_default_php_ini
+{
+foreach my $ai (split(/\t+/, $config{'php_ini'})) {
+       local ($f, $d) = split(/=/, $ai);
+       return $f if (-r $f);
+       }
+return undef;
+}
+
 # list_php_configs()
-# Returns 1 list of allowed config files and descriptions
+# Returns a list of allowed config files and descriptions
 sub list_php_configs
 {
 local @rv;