Codeigniter PHP Fatal error: log_message() since php7


Since I’ve upgraded to php7, my codeigniter project get a error.

PHP Fatal error: log_message(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition “CI_Log” of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /path/to/my/project/system/core/Common.php on line 478

But… I’ve never use the log_message() function in my code. :sweat_smile: (And didn’t modified any line of the CI core)

Codeigniter 3.0.1. (Maybe should I try to use the 3.0.2 ?)

I’d say either that or hack

IMHO probably better to update to latest as core file hacks can sometimes cause more trouble than they solve .

Not that you won’t get any other problems (deprecateds, parameter changes etc. check the changelog)

I’ve just updated to 3.0.2.

That isn’t better.

What do you say by “hack” ? disable this function ? by a return 1 at the start of this function for example ?

No, the error is that

I’m guessing it would be easier to add the autoload

1 Like

Solution (hack):

core/common.php:478, change this line by adding a @ at the start.
@$_log[0]->write_log($level, $message);

I Ignore this error. Not the better solution.

Thank @Mittineague.

See more information about error control operator.


I have not used PHP7 yet and looking forward to trying once my developer system is set up.

Have you reported this bug to CodeIgniter Issues? I believe the developer team are making the latest CI versions PHP7 compatible.

Another way to suppress the error:

// turnoff all error_reporting and save previous setting
$oldErrorReporting = error_reporting(0); 
   $_log[0]->write_log($level, $message);

// restore previous error_reporting settings
   error_reporting( $oldErrorReporting );	

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.