• Resolved frameitphoto

    (@frameitphoto)


    My web host is forcing me to switch to PHP 5.4. I was on 5.3 and they won’t force the switch until next April so plenty of time. Well I switched anyway (although I can go back). An got a problem.

    I use the Pagelines Platform theme and two of it’s PHP files are throwing errors and lots of them. I detail two below.

    The first one throws the error on this line (there are quite a few like this):
    $this->hidden->text = '';

    The error is: Warning: Creating default object from empty value in /wp-content/themes/platform/includes/class.layout.php on line 167

    So I found a way to fix it by adding this if statement before the lines like:

    if (!is_object($this->hidden)) {
    					$this->hidden = new stdClass;
    				}
    $this->hidden->text = '';

    Now that works and resolved all lines like that. Then I got this type of line with the same warning:

    $this->dcol[ $number_of_columns ]->container_width = $this->content->width + $column_gutter - $round_amount;

    I tried adding the if statement as above but got an error about an array not being stdClass. This is where my talents runs out and I don’t know how to create the if statement to stop it warning about these lines. So, I commented the lines out and tested my site. It still works, as expected on every single page.

    I suppose some people would call that a fix, but I am nervous that this will come back and bite me if i do something new or different on the site in the future, so ideally I want to fix it.

    I’m on a shared 1&1 so can’t get at php.ini to stop warnings showing, and I’ve tried varying ideas with custom php.ini files in sub folders and mods to .htaccess – all with no luck.

    Any help on the sytax around the if statement for the array would be really helpful.

    Thanks

    David

Viewing 7 replies - 1 through 7 (of 7 total)
  • add to wp-config.php
    ini_set( ‘display_errors’, 0 );

    shared hosts always have display_errors on, helps keep the support costs and log size down.

    By default PHP has this set to 0 for production servers.

    Thread Starter frameitphoto

    (@frameitphoto)

    Oh thank you so much.

    I tried something very similar to this but it didn’t work

    ini_set( 'display_errors', 'off' );

    Initially your version didn’t until I moved it to the top of wp-config and not the bottom.

    Superb!!!!

    One happy camper and just goes to show it’s worth asking in the forums 🙂

    Cheers

    David

    My issue is similar.
    I duplicated a live site on local (WAMP) setup.

    Everything looks fine but the dashboard says:
    “Creating default object from empty value in D:\wamp\www\test\wp-admin\includes\update.php on line 90”

    I do not know what this means or how to fix it.

    Please ignore me if this is irrelevant but help me if you can.

    Thank you.

    got the same error – this is in wp_version_check – cant it be turned off?

    I fixed this by editing the file that was giving the warning (/wp-content/themes/platform/includes/class.layout.php), inserting this at the beginning to disable warnings:

    error_reporting(E_ERROR);

    Thank you so much it worked for me.

    Moderator bcworkz

    (@bcworkz)

    Apparently people with error handling issues keep hitting this thread on search.

    The ideal error handling configuration will vary greatly with the nature of your site. Instead of simply copying what someone else did — a complete stranger you don’t know and don’t know their site’s nature, you should really consider your own needs and configure your site accordingly.

    This topic is somewhat confusing, but if you take some time to study the documentation, you too can arrive at the perfect configuration for your needs.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Warning Error – creating default object from empty value’ is closed to new replies.