WordPress and updating PHP beyond 5.3

My host finally set up the ability to upgrade PHP.  I’ve been running on 5.2 for roughly forever.  I host for clients, and most upgrades went without a hitch.  A couple, however, barfed a bit thanks to undeclared variables, generated errors the likes of:

Warning: Creating default object from empty value in \wp-content\themes\hybrid\library\functions\core.php on line 27

Thankfully, it’s a pretty easy fix: just declare the variable! for example,

if ( post_type_supports( $post->post_type, 'entry-views' ) ) {
$entry_views->post_id = get_queried_object_id();

In a library/extensions file generated a warning. To fix, I simply declared the variable $entry_views:

if ( post_type_supports( $post->post_type, 'entry-views' ) ) {
if (!is_object($entry_views)) {$entry_views = new stdClass; }
$entry_views->post_id = get_queried_object_id();

I had to do the same in a few other files as well.

One comment

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*