Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Warning: Creating default object from empty value

My first time posting, I'm hoping someone could help me with this error that has appeared on my website as of Wednesday, I'm not sure how to correct it since I've never touched the .php file.

If I could get some help, I would be really appreciative of it.

The website with error, located at the top of the page.

The error is:

Warning: Creating default object from empty value in whitelight/functions/admin-hooks.php on line 160

Here is the code from lines 150 -170

like image 679
Cassie Avatar asked Jun 21 '13 23:06

Cassie


2 Answers

This probably means that your host has upgraded the server to php 5.4.x. Please reference this page on how to solve the issue: PHP 5.4: disable warning "Creating default object from empty value"

In summary, You either need have your own error handler or if this is the only place that it occurs then you just need to make it a stdClass before making it an array like so:

} // End IF Statement

if ( !is_object( $query_context ) ) {
  $query_context = new stdClass(); 
}         

$query_context->context = array();

It is also possible that upgrading wordpress and its plugins would solve the problem. I don't know much about that area though...

like image 68
immulatin Avatar answered Nov 17 '22 08:11

immulatin


The following 2 lines should be added to admin-hooks.php just before the if statement on line 160:

$query_context = new stdClass();
$query_context->context = array();
like image 2
Richard Avatar answered Nov 17 '22 08:11

Richard