+@@ -593,14 +611,28 @@
+
+ {
+ zval tmp;
++ // use main php.ini if loaded
++ // see https://github.com/pld-linux/php/commit/762ec2e
++ // test with:
++ // php -r 'var_dump(array(get_cfg_var("cfg_file_path"),php_ini_loaded_file()));'
++ if (php_ini_loaded_file) {
++ if (fh.filename) {
++ efree((char *)fh.filename);
++ }
++ fh.filename = php_ini_loaded_file;
++ }
+
+ ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1));
+ zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp);
+ if (opened_path) {
+ zend_string_release(opened_path);
+- } else {
++ }
++
++ if (fh.filename) {
+ efree((char *)fh.filename);
++ fh.filename = NULL;
+ }
++
+ php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
+ }
+ }
+@@ -624,13 +656,15 @@