Zen Cart Logo
Forums / Bug Reports / PHP Warning: A non-numeric value encountered in categories_ul_generator.php line 73

PHP Warning: A non-numeric value encountered in categories_ul_generator.php line 73

Views: 4,853

Results 1 to 2 of 2
12 Dec 2018, 3:45 PM
#1
brittainmark avatar

brittainmark

Totally Zenned

Join Date:
Apr 2009
Posts:
507
Plugin Contributions:
1

PHP Warning: A non-numeric value encountered in categories_ul_generator.php line 73

[Note: ZC version 1.5.5.f, , PHP version 7.2, etc ]
I think you have fixed this bug in 1.5.6. But was reading the php manual as I think the warning occoured as a result of moving from 7.0 to 7.2. Have same issue in 7.1.
In 1.5.6 you have inserted php $level = (int)$level; in \includes\classes\categories_ul_generator.php line 58 to change the '' string that you have to 0 (zero) the manual suggest that casting a string to integer if fine if it contains numbers however it suggest the any other behaviour could change without warning. Could i suggest that perhaps you should consider changing the call in the same module line 86 from```php
function buildTree($submenu=false)
{
return $this->buildBranch($this->root_category_id, '', $submenu);
}

to ```php
 function buildTree($submenu=false)
    {
        return $this->buildBranch($this->root_category_id, NULL, $submenu);
    }

this appears to solve the issue.
Regards
Mark

15 Dec 2018, 9:54 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: PHP Warning: A non-numeric value encountered in categories_ul_generator.php line 73

Thanks.

The "$level = (int)$level;" fix is sufficient for all known PHP versions.

Your suggestion of switching to NULL is noted (and good), however in doing that I'd make a few more changes. We will consider that for a future update. In the meantime, the v156 code contains a suitable fix.