@anonymous-piwik-user opened this Issue on June 8th 2010

Hi,

this time I have a solution. So, in the Piwik_Config::init() method, the is_readable($this->pathIniFileUserConfig) is made after the attempt to read the config file. I think the code should be swapped to look like this:

if(!is_readable($this->pathIniFileUserConfig))
        {
            die("The configuration file {$this->pathIniFileUserConfig} has not been found.");
        }
        $this->defaultConfig = new Piwik_Config_Ini($this->pathIniFileDefaultConfig, null, true);

Also note that I've placed a die instead of throwing an exception. The exception was silent, and no error where displayed about the config not found.

And then, many critical error were occuring because the config was missing. So a die() statement looked like useful at this place as we don't want the excecution to continue.

@robocoder commented on June 9th 2010 Contributor

Sorry, what problem is this a solution for?

The exception is used to launch the installer. (See core/FrontController.php)

@anonymous-piwik-user commented on June 9th 2010

the is_readable() is made after the attempt to read the config file.

... the file is read before knowing if you can read it. In my case, you couldn't (file doesn't exist), so an uncatched exception was thrown.

@robocoder commented on June 9th 2010 Contributor

Can you post a stacktrace for this code path?

Normally, this is caught by core/FrontController, which then launches the installer.

@anonymous-piwik-user commented on June 9th 2010

No, I cannot really do it, as I've fixed the code on my installation & I'm configured & I've desactivated XDebug as the site is now in production.

But just try to remove your config file, you should reproduce the bug.

And even without reproducing, just look at the "logic" behind the code:
Read a file, and then check if it's readable... what's the point ?

@robocoder commented on June 9th 2010 Contributor

I see.

The patch is wrong, but I'm testing a fix now. Thanks.

@robocoder commented on June 9th 2010 Contributor

(In [2290]) fixes #1415 - prettier error messages for misconfigurations

tested all possible combinations:

  • config/ directory not readable
  • config/global.ini.php not readable (but exists)
  • config/global.ini.php doesn't exist
  • config/global.ini.php empty
  • config/global.ini.php exists and:
    • config/config.ini.php not readable (but exists)
    • config/config.ini.php doesn't exist; triggers installer
    • config/config.ini.php empty
  • config/global.ini.php and config/config.ini.php both exist; normal
This Issue was closed on June 9th 2010
Powered by GitHub Issue Mirror