midgardproject / midgard-php5

PHP5 API for Midgard persistent storage framework
http://www.midgard-project.org/api-docs/midgard/php/ratatoskr/
GNU Lesser General Public License v2.1
9 stars 2 forks source link

mgd2 extension breaks PHP if one config file is not readable #89

Open flack opened 12 years ago

flack commented 12 years ago

Steps to reproduce:

Expected Result:

Actual Result:

PHP Warning:  Failed to read my_new_config config file. Permission denied in Unknown on line 0
PHP Warning:  [Midgard2 minit] Failed to initialize configs in Unknown on line 0
PHP Fatal error:  Unable to start midgard2 module in Unknown on line 0

I should add that the new config file is not even referenced in php.ini or anything. But mgd2 seems to check all files in the folder for some reason, and if one of them is not readable, you can't run any php code until you fix this

piotras commented 12 years ago

That is correct. Please make sure midgard.http is Off for cli. This "unclear" and implicit behavior is done to make it possible to read config files with root permission before the privileges are dropped.

flack commented 12 years ago

What I don't understand is why config files have to be read in the first place? Wouldn't it be better to do a lazy lookup, i.e. search for the file only when read_config or something similar is called?

I can of course change the config, but this requires further customization, since in Ubuntu (and Debian, too, I think), the php conf.d is a symlink, so by default all sapis use the same midgard config. It's not such a big deal, but yet another customization you have to remember to do when installing a new midgard server

piotras commented 12 years ago

This is the nature of PHP. We have to register classes when module is loaded. read_config() to open connection is one thing, register classes is another one.