totten / civix

CiviCRM Extension Builder
http://civicrm.org/
Other
56 stars 56 forks source link

Obscure errors when CMS configuration not fully readable #81

Open brettcs opened 7 years ago

brettcs commented 7 years ago

Debian 8's drupal7 package splits the Drupal configuration into two files: a general settings.php file, which is owned root:root and has 0644 permissions, and a dbconfig.php file, which is owned root:www-data and has stricter 0640 permissions. settings.php runs require_once('dbconfig.php');.

Unless you're running as the web server user www-data, trying to run civix with this configuration generates an error about failing to load dbconfig.php, and causes civix to fail:

shell% civix generate:module org.brettcsmith.teste
License set to AGPL-3.0 (authored by Brett Smith <brettcsmith@brettcsmith.org>)
If this is in error, please correct info.xml and LICENSE.txt
Initalize module org.brettcsmith.teste
Write org.brettcsmith.teste/info.xml
Write org.brettcsmith.teste/teste.php
Write org.brettcsmith.teste/teste.civix.php
Write org.brettcsmith.teste/LICENSE.txt
PHP Fatal error:  require_once(): Failed opening required 'dbconfig.php' (include_path='.:/var/lib/drupal7/modules/civicrm:/var/lib/drupal7/modules/civicrm/packages:/var/lib/drupal7/modules/civicrm/vendor/tecnickcom:/var/lib/drupal7/modules/civicrm/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/drupal7/sites/default/modules/civicrm:/usr/share/drupal7/sites/default/modules/civicrm/packages:.:/usr/share/php:/usr/share/pear') in /etc/drupal/7/sites/default/settings.php on line 182

Fatal error: require_once(): Failed opening required 'dbconfig.php' (include_path='.:/var/lib/drupal7/modules/civicrm:/var/lib/drupal7/modules/civicrm/packages:/var/lib/drupal7/modules/civicrm/vendor/tecnickcom:/var/lib/drupal7/modules/civicrm/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/drupal7/sites/default/modules/civicrm:/usr/share/drupal7/sites/default/modules/civicrm/packages:.:/usr/share/php:/usr/share/pear') in /etc/drupal/7/sites/default/settings.php on line 182

I addressed this problem on my system by giving my local user account read access to dbsettings.php.

I know it's probably not possible to anticipate every possible problem that could occur while loading a user's CRM settings, but it might be nice if civix could notice that an error happened and explain a little more that this means it couldn't fully load the CRM configuration. Especially since this is Debian's stock configuration, it seems like this could be a common error for users to run into.

totten commented 7 years ago

Hmm, yeah, I can see how the clarity/obscurity of that error would be... debatable. The message does seem like a pretty accurate description of the problem, and I'm struggling to imagine a general error-handler/error-reporter which would make it clearer. (Unless you just handle it has a special-case specifically for Debian's Drupal package?)