Question

I have two identical Debian Squeeze servers running php 5.3.3-7+squeeze17, one running 1.7.x, the other 2.1.4.

On the 1.7 installation, when I call a controller method that calls an undefined model method, the page outputs:

Fatal error: Call to undefined method Example_Model::get_series_and_products() in /opt/git/online_live/application/controllers/members.php on line 2549

However, on 2.1.4 there is no output at all. echo statements inserted before the undefined function output text, but statements after do not.

Both sites have php error_reporting set to -1 in their VirtualHost config, which seems to override the config.php defined ENVIRONMENT setting of development, which sets error_reporting to E_ALL.

Here's some extra code I'm using for output:

echo ini_get('error_reporting');
echo '<br>';
echo phpversion();

Which outputs the same on both:

-1  
5.3.3-7+squeeze17

So, it would not appear that anything else is trumping my error_reporting.

In application/config/config.php in 2.1.4 (where the error's not showing):

$config['log_threshold'] = 4; // All Messages

In 1.7 (where the error is showing):

$config['log_threshold'] = 0;

But I thought that setting was for the file system log that CI keeps and not inline errors.

phpInfo() reflects the same error_log values on both hosts:

error_log:              no value    no value
error_reporting:        -1          22527

What could be causing the difference?

Was it helpful?

Solution

EDIT: This does not apply if your setting was set using php_admin_value or php_admin_flag. Thanks to jaydisc for enlightening me about this fact. The answer lay in the display_error directive, which governs the display of errors instead.

However, I am leaving the rest of the post here because based on the question title, this would be a possible answer if not for the php_admin_value setting.

Error Reporting Difference between 1.7.x and 2.x

Regardless of your error_reporting settings, Codeigniter overwrites it in the index.php. http://php.net/manual/en/function.error-reporting.php

The error_reporting() function sets the error_reporting directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script.

This is as error_reporting belongs to a family of ini_set functions: http://php.net/manual/en/function.ini-set.php, which override php directives for the duration of the script, including the php_admin_value.

For 1.7.x, (looking at old versions here http://ellislab.com/codeigniter/user-guide/installation/downloads.html),

the first line of code in index.php is

error_reporting(E_ALL);

, which enables errors no matter what (unless the setting is changed via the code later).

For 2.1.4, (https://github.com/EllisLab/CodeIgniter/blob/2.1.4/index.php) it depends on the ENVIRONMENT constant:

/*
 *---------------------------------------------------------------
 * ERROR REPORTING
 *---------------------------------------------------------------
 *
 * Different environments will require different levels of error reporting.
 * By default development will show errors but testing and live will hide them.
 */

if (defined('ENVIRONMENT'))
{
    switch (ENVIRONMENT)
    {
        case 'development':
            error_reporting(E_ALL);
        break;

        case 'testing':
        case 'production':
            error_reporting(0);
        break;

        default:
            exit('The application environment is not set correctly.');
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top