Quantcast
Channel: David Mudrak's blog » php
Viewing all articles
Browse latest Browse all 6

Forcing Moodle and any other PHP application to always display errors

$
0
0

Again, I ran into situation when a very o{l|d}d installation of Moodle displayed just an empty page instead of a useful error message. That’s why I again had to play a bit with all these error_reporting and display_error settings. Let me summarise how it works – at least as far as I know.

There are basically four places where PHP configuration parameters can be defined: 1) php.ini, 2) httpd.conf 3) .htaccess and 4) source code itself.

The file php.ini contains site-wide PHP configuration. You can define parameters by assigning them a value – eg display_errors=1

PHP configuration can be defined in Apache configuration as well (either in httpd.conf or a sub-config file included by it). This allows you to redefine defaults from php.ini for a particular directories. You can use statements like php_flag to php_value do it. Or, you can use php_admin_flag or php_admin_value to do the same with the exception that the later form can not be redefined at a lower level again.

If you have “AllowOverride Options” defined in Apache for the given location, you can use .htaccess files to redefine PHP settings. The statements php_flag or php_value can be used in .htaccess files. The forms php_admin_* are not supported at this level.

Finally, you can modify some settings by ini_set() or error_reporting() PHP commands. It seems to me that these are at the same level as .htaccess is. I mean – IMHO there is no way how to disable ini_set() in .htaccess.

What I needed was to disable Moodle code to call error_reporting(0) and ini_set(‘display_errors’, 0). Therefore I had to go a relevant httpd.conf section and use

php_admin_flag display_errors on
php_admin_value error_reporting 2147483647

With this settings, neither .htaccess nor source code itself is able to hide any error message any more.


Viewing all articles
Browse latest Browse all 6

Trending Articles