Zen Cart Logo
Forums / ZCDEV - v2-Development Bugs / Bug in v1.6.0 class.base.php

Bug in v1.6.0 class.base.php

Views: 3,061

Results 1 to 6 of 6
23 Jul 2013, 6:43 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Bug in v1.6.0 class.base.php

The notify function in the current v1.6.0 /includes/classes/class.base.php (https://github.com/zencart/zencart/blob/v160/includes/classes/class.base.php) has a small issue. Since the NOTIFIER_TRACE value is always a string, the fragment NOTIFIER_TRACE != 0 of the following statement never evaluates to true, causing the if-clause to never be executed.

   if (defined('NOTIFIER_TRACE') && NOTIFIER_TRACE != '' && NOTIFIER_TRACE != 0 && NOTIFIER_TRACE != FALSE && NOTIFIER_TRACE != 'false') {

To correct, either remove the fragment or convert it to an exact-match:

   if (defined('NOTIFIER_TRACE') && NOTIFIER_TRACE != '' && NOTIFIER_TRACE !== 0 && NOTIFIER_TRACE != FALSE && NOTIFIER_TRACE != 'false') {
23 Jul 2013, 7:27 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Bug in v1.6.0 class.base.php

Once I corrected the above, many debug log files were generated with:

[23-Jul-2013 20:33:37] PHP Warning:  array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in C:\xampp\htdocs\testsite\includes\classes\class.base.update.php on line 58

which results from the following:

$paramArray = array_merge($param1,$param2,$param3,$param4,$param5,$param6,$param7));

To get rid of the PHP warnings (I'm running PHP 5.4.8) and to not flood the already going-to-be-large file with meaningless information, I recoded that line as

      $paramArray = $param1;
      for ($i = 2; $i < 8; $i++) {
        $param_n = "param$i";
        if ($$param_n !== NULL) {
          $paramArray[$param_n] = $$param_n;
        }
      }

That not only removes the warning but also includes the $param{1-7} values ***only ***if they've been specified.

23 Jul 2013, 7:38 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Bug in v1.6.0 class.base.php

lat9:

Since the NOTIFIER_TRACE value is always a string
Why is that?
Can't it be defined as an integer, or a boolean?

23 Jul 2013, 7:52 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Bug in v1.6.0 class.base.php

It's coming out of the database, so it's always a string value. In the plugin version, the value can be either 'true' or 'false'; in the v1.6.0 version, it looks like the value can be set to 'true', 'print_r', 'var_export' or 'var_dump' ... none of which will evaluate true with the 'NOTIFIER_TRACE != 0' portion of the if-statement.

23 Jul 2013, 7:58 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Bug in v1.6.0 class.base.php

lat9:

It's coming out of the database, so it's always a string value.
Oops - I was still thinking it was just a define in a custom PHP file.

23 Jul 2013, 8:00 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Bug in v1.6.0 class.base.php

In the plugin version, it's controllable via a setting in Configuration->Logging ...