Zen Cart Logo
Forums / General Questions / "PHP Warning: Creating default object from empty value" what is this?

"PHP Warning: Creating default object from empty value" what is this?

Views: 2,051

Results 1 to 4 of 4
25 Nov 2013, 2:58 AM
#1
gsmsalers avatar

gsmsalers

New Zenner

Join Date:
Feb 2009
Posts:
71
Plugin Contributions:
0

"PHP Warning: Creating default object from empty value" what is this?

Hi.
My Zencart version is 1.51.
My website was working perfectly on my test live server, until I migrated hosting to another server. Then I got several bugs, which might be caused by PHP version incompatibility. First I dealt below problem.
http://www.zen-cart.com/showthread.php?207435-php-5-4-fatal-error-Allowed-memory-size-of-83886080-bytes-exhausted/page2

Now I got below error log file. Something is wrong in admin area.
[25-Nov-2013 02:48:41 UTC] PHP Warning: Creating default object from empty value in /home/myhosting/public_html/admin/categories.php on line 986

What is this problem?

25 Nov 2013, 3:26 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: "PHP Warning: Creating default object from empty value" what is this?

gsmsalers:

Hi.
My Zencart version is 1.51.
My website was working perfectly on my test live server, until I migrated hosting to another server. Then I got several bugs, which might be caused by PHP version incompatibility. First I dealt below problem.
http://www.zen-cart.com/showthread.php?207435-php-5-4-fatal-error-Allowed-memory-size-of-83886080-bytes-exhausted/page2

Now I got below error log file. Something is wrong in admin area.
[25-Nov-2013 02:48:41 UTC] PHP Warning: Creating default object from empty value in /home/myhosting/public_html/admin/categories.php on line 986

What is this problem?

Would need to look at the file /admin/categories.php then look at line 986; however, believe this statement has been discussed recently related upgrading to PHP 5.4. If not mistaken that line uses a variable that hasn't previously been declared, and therefore the warning.

The fix they had (which was for a different application) was similar to: $variable = new variable_type

where variable_type might be a class or other type of variable.

Though still looking through categories.php, it looks like there are case statements that assign one or both variables used on that line. Thing is that I haven't been able to determine if every case statement makes a guaranteed statement, even if it is to declare the variable(s), but it could be possible that the path taken by the data excluded assignment of one or both of the variables associated with that line.

25 Nov 2013, 10:22 AM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: "PHP Warning: Creating default object from empty value" what is this?

These are not bugs as such, just php error reporting getting stricter and tightening the "rules".
I would have said just have a look at the corresponding files in the 1.60 files on Github for a clue...but I have done that and didn't see the obvious answer so...some input required from the cognescenti.

9 May 2014, 5:54 PM
#4
d0ugparker avatar

d0ugparker

Zen Follower

Join Date:
May 2008
Location:
Near the water, somewhere...
Posts:
129
Plugin Contributions:
0

Re: "PHP Warning: Creating default object from empty value" what is this?

Bump. I'm on 1.5.1.

Hopefully not a big deal, but I'd like to find if there's a
known fix to this by now that I can read and implement.
I just noticed I've been receiving similar log notices in
my log file:

[09-May-2014 11:01:24 America/New_York] PHP Warning: Creating default object from empty value in /storeLocation/includes/modules/shipping_estimator.php on line 117

Here's a snippet from shipping_estimator.php, and a little
bookmark code before and after. I've indicated by a
comment where my line 117 is in the code.

    // user not logged in !
    if (isset($_POST['zone_country_id'])){
      // country is selected
      $_SESSION['country_info'] = zen_get_countries($_POST['zone_country_id'],true);
      $country_info = $_SESSION['country_info'];
      $order->delivery = array('postcode' => $zip_code,
                               'country' => array('id' => $_POST['zone_country_id'], 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                               'country_id' => $_POST['zone_country_id'],
                               //add state zone_id
                               'zone_id' => $state_zone_id,
                               'format_id' => zen_get_address_format_id($_POST['zone_country_id']));
      $_SESSION['cart_country_id'] = $_POST['zone_country_id'];
      //add state zone_id
      $_SESSION['cart_zone'] = $state_zone_id;
      $_SESSION['cart_zip_code'] = $zip_code;
    } elseif ($_SESSION['cart_country_id']){
      // session is available
      $_SESSION['country_info'] = zen_get_countries($_SESSION['cart_country_id'],true);
      $country_info = $_SESSION['country_info'];
      // fix here - check for error on $cart_country_id
      $order->delivery = array('postcode' => $_SESSION['cart_zip_code'],
                               'country' => array('id' => $_SESSION['cart_country_id'], 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                               'country_id' => $_SESSION['cart_country_id'],
                               'zone_id' => $state_zone_id,
                               'format_id' => zen_get_address_format_id($_SESSION['cart_country_id']));
    } else {
      // first timer
      $_SESSION['cart_country_id'] = STORE_COUNTRY;
      $_SESSION['country_info'] = zen_get_countries(STORE_COUNTRY,true);
      $country_info = $_SESSION['country_info'];
      //**************************
      // line 117 follows
      //**************************
      $order->delivery = array(//'postcode' => '',
                               'country' => array('id' => STORE_COUNTRY, 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                               'country_id' => STORE_COUNTRY,
                               'zone_id' => $state_zone_id,
                               'format_id' => zen_get_address_format_id($_POST['zone_country_id']));
    }
    // set the cost to be able to calculate free shipping
    $order->info = array('total' => $_SESSION['cart']->show_total(), // TAX ????
                         'currency' => $currency,
                         'currency_value'=> $currencies->currencies[$currency]['value']);
  }

Warm regards,

Doug