[Done v1.5.4] PHP 5.4 PHP Warning: Creating default object from empty value
This is an informational post...hopefully it will save someone else the time I spent on this.
After upgrading my local Windows 7 test server to Xampp 1.80: php 5.4.4 I started getting debug logs being created from the admin.
[27-Sep-2012 16:10:25 UTC] PHP Warning: Creating default object from empty value in D:\blah blah\public_html\tienda\MY_ADMIN\categories.php on line 1018
Which is:
PHP Code:
if (empty($pInfo->products_id)) {
line 1018 $pInfo->products_id= $pID;
It happens in Admin->Catalog->Categories/Products when doing a search that yields a result that includes categories (but for no result/a result with products only,..no debug log is created).
I have a copy of my shop (upgraded to 1.51) and a vanilla 1.51 install on the same server. The vanilla install did not cause the debug log.
As it was “obviously” a problem with my shop I spent a lot of time investigating that avenue...nothing.
The error reporting seemed to be the same in the shop files and ZC151 files, and php.ini between the old Xampp 1.73 php 5.3.1. and the new 1.80 php 5.4.4.
Eventually I found that in php 5.4 the buggers have included E_STRICT error reporting in E_ALL so the warnings were from E_STRICT being implemented: obvious when you work with php all the time..which I don’t.
Further to this adding the extra line cures the warning.
PHP Code:
if (empty($pInfo->products_id)) {
$pInfo = new stdClass();
$pInfo->products_id= $pID;
So....why does the vanilla ZC151 not produce the error? Obviously there's an E_ALL lurking somewhere in my files but I’ve looked at all the instances of E_ALL in my shop and the vanilla, and commented out any extras in my mods...still haven’t found why there is a difference in the error reporting...so this post does not go in the bug reports!
Re: PHP 5.4 Error Reporting E_STRICT in E_ALL causing a warning debug log on my site
moved to bug reports forum.
Will investigate and schedule a fix where necessary.
Re: PHP 5.4 Error Reporting E_STRICT in E_ALL causing a warning debug log on my site
Re: PHP 5.4 Error Reporting E_STRICT in E_ALL causing a warning debug log on my site
Also occurs for /admin/products_price_manager.php:
Code:
[22-Nov-2012 16:18:43 Europe/Berlin] PHP Warning: Creating default object from empty value in C:\xampp\htdocs\v1.5.1\myadmin\products_price_manager.php on line 476
[22-Nov-2012 16:18:43 Europe/Berlin] PHP Warning: Creating default object from empty value in C:\xampp\htdocs\v1.5.1\myadmin\products_price_manager.php on line 482
Re: PHP 5.4 Error Reporting E_STRICT in E_ALL causing a warning debug log on my site
Also occurs for /includes/modules/shipping_estimator.php:
Code:
[25-Nov-2012 16:22:21 Europe/Berlin] PHP Warning: Creating default object from empty value in C:\xampp\htdocs\mystore\includes\modules\shipping_estimator.php on line 107
Code:
[27-Nov-2012 17:29:35 Europe/Berlin] PHP Warning: Creating default object from empty value in C:\xampp\htdocs\mystore\includes\modules\shipping_estimator.php on line 117
It looks like the solution for this one might be (starting at line 63 of the v1.5.1 module):
Code:
//if($cart->get_content_type() !== 'virtual') {
require(DIR_WS_CLASSES . 'order.php');
$order = new order;
if ($_SESSION['customer_id']) {
// user is logged in
if (isset($_POST['address_id'])){
// user changed address
$sendto = $_POST['address_id'];
}elseif ($_SESSION['cart_address_id']){
// user once changed address
$sendto = $_SESSION['cart_address_id'];
// $sendto = $_SESSION['customer_default_address_id'];
}else{
// first timer
$sendto = $_SESSION['customer_default_address_id'];
}
$_SESSION['sendto'] = $sendto;
// set session now
$_SESSION['cart_address_id'] = $sendto;
// set shipping to null ! multipickjup changes address to store address...
$shipping='';
// include the order class (uses the sendto !)
// require(DIR_WS_CLASSES . 'order.php');
// $order = new order;
}else{
// user not logged in !
Re: PHP 5.4 and PHP Errors
To address these warnings, add the highlighted changes to your code:
Quote:
Originally Posted by
Kamino84
PHP Warning: Creating default object from empty value in /homepages/38/d436025994/htdocs/includes/modules/payment/authorizenet_aim.php on line 429
Code:
function admin_notification($zf_order_id) {
global $db;
$output = '';
$aimdata = new stdClass;
$aimdata->fields = array();
Quote:
Originally Posted by
Kamino84
PHP Warning: Illegal string offset 'id' in /homepages/38/d436025994/htdocs/includes/modules/payment/paypalwpp.php on line 199
Code:
function update_status() {
global $order, $db;
// $this->zcLog('update_status', 'Checking whether module should be enabled or not.');
if ($this->enabled && (int)$this->zone > 0 && isset($order->billing['country']['id'])) {
Re: PHP 5.4 and PHP Errors
Thanks for the quick reply and fix. As mentioned before I dont think it was causing an problems with the software functioning just a log file mess when they start to stack up. It appears php 5.4 is a bit more strict with the calling of objects and error logging.
Shipping estimator not working correctly ERROR MSG.
:blink:
[07-Feb-2013 05:33:03 Australia/Melbourne] PHP Warning: Creating default object from empty value in /homepages/../../htdocs/store/includes/modules/shipping_estimator.php on line 117
thanks, Lora
Re: Shipping estimator not working correctly ERROR MSG.
it also has the same error message for line 117, 107, 92