Forums / Bug Reports / Admin categories search -Creating default object from empty value (see in debug logs)

Admin categories search -Creating default object from empty value (see in debug logs)

Results 1 to 12 of 12
13 Jan 2015, 23:44
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Posts:
2,850
Plugin Contributions:
3

Admin categories search -Creating default object from empty value (see in debug logs)

vanilla install (+superglobals and backup mysql), local XAMPP install, MySQL 5.6.21, PHP 5.6.3

Go into catalog and search for "music": an admin debug log is created.

PHP Warning: Creating default object from empty value in ...\zc154\admin1\categories.php on line 1006

line 1006
[PHP] $pInfo->products_id= $pID;[/PHP]

Seems to be when a category is returned from a search, not nothing or products-only.
14 Jan 2015, 02:46
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Admin categories search -Creating default object from empty value (see in debug logs)

I can reproduce this on my Zen Cart v1.5.4 when I have php 5.5 but not on my Zen Cart v1.5.4 when I have php 5.3.28 or php 5.3.29 ...

We will have to check into this further ...
14 Jan 2015, 06:07
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Admin categories search -Creating default object from empty value (see in debug logs)

Any interesting point is that this appears to only be triggered when both 1 or more Categories and 1 or more Products are found in the search, such as in 'music' which is both a Category and a Product ...

This will not trigger when only 1 or more Products are found, such as a search on 'DVD-DHWV' ...

This will not trigger when only 1 or more Categories are found and no Products ...
14 Jan 2015, 08:24
#4
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Posts:
2,850
Plugin Contributions:
3

Re: Admin categories search -Creating default object from empty value (see in debug logs)

My hosting is php 5.4.34, does it there too.
14 Jan 2015, 08:39
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Admin categories search -Creating default object from empty value (see in debug logs)

It's a result of PHP 5.4 becoming more strict in how it handles uninitialized objects.

Fortunately it's only throwing a minor "warning", and not a fatal error.

The solution may require a number of architectural changes, which may be relevant in other places also, so probably will be incorporated into a new version, and not treated as critical bugs.
14 Jan 2015, 21:18
#6
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Posts:
2,850
Plugin Contributions:
3

Re: Admin categories search -Creating default object from empty value (see in debug logs)

I use the search extensively, could a few strategically placed "@" suppress the creation of these logs?
14 Jan 2015, 22:02
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Admin categories search -Creating default object from empty value (see in debug logs)

Before you bother with suppressing things, where *else* in the admin are you able to trigger the same kind of message?
14 Jan 2015, 22:19
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Posts:
2,850
Plugin Contributions:
3

Re: Admin categories search -Creating default object from empty value (see in debug logs)

I haven't seen it occur anywhere else.
14 Jan 2015, 23:30
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Admin categories search -Creating default object from empty value (see in debug logs)

To get rid of that warning entry in the log file, you can remove those lines causing it, as they're not used. It appears they're leftover from when that file was split into multiples for (slightly) easier maintenance:

These at 1005-1007 in /admin/categories.php can be removed:
[strike]
  if (empty($pInfo->products_id)) {
    $pInfo->products_id= $pID;
  }
[/strike]
15 Jan 2015, 14:49
#10
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Posts:
2,850
Plugin Contributions:
3

Re: Admin categories search -Creating default object from empty value (see in debug logs)

Additional information is that prior to commenting-out those lines, I found a note in my categories file at another point
[PHP]if (empty($pInfo->products_id)) {
//$pInfo = new stdClass();//steve added to 1.53 for php 5.4 and E_STRICT warnings, removed for 1.54, maybe fixed?
$pInfo->products_id= $pID;
}[/PHP]
If I re-enable that commented-out declaration, the error log does not occur.

Which "solution" is recommended, or it really doesn't matter?
15 Jan 2015, 14:56
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Admin categories search -Creating default object from empty value (see in debug logs)

Your suggestion works; however, I don't see where that object is used after that point in the code, hence the suggestion to simply remove it.
15 Jan 2015, 16:40
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Admin categories search -Creating default object from empty value (see in debug logs)

torvista:

Additional information is that prior to commenting-out those lines, I found a note in my categories file at another point
[PHP]if (empty($pInfo->products_id)) {
//$pInfo = new stdClass();//steve added to 1.53 for php 5.4 and E_STRICT warnings, removed for 1.54, maybe fixed?
$pInfo->products_id= $pID;
}[/PHP]

Indeed, you had posted about that very thing in another thread, but it got lost due to hijacked discussions that got added to it. Apologies that it got missed in 1.5.4.