Forums / Upgrading to 1.5.x / A non-numeric value ?

A non-numeric value ?

Views: 1,996

Results 1 to 8 of 8
3 Feb 2018, 12:41 AM
#1
ang_l avatar

ang_l

New Zenner

Join Date:
Jan 2017
Location:
Bulgaria
Posts:
11
Plugin Contributions:
0

A non-numeric value ?

Hi,
I upgrade to 1.5.5f, but i think the error is comming after i change PHP Version to 7.1
that is from MyDEBUG fail :

PHP Warning: A non-numeric value encountered in /home/ga.....m/includes/classes/categories_ul_generator.php on line 58
zen_categories_ul_generator->buildBranch() called at [/h ... ludes/classes/categories_ul_generator.php:85]
zen_categories_ul_generator->buildTree() called at [/ho ... /includes/templates/westminster_new/templates/tpl_modules_mobile_categories_tabs.php:122]
require(/hom... /includes/templates/westminster_new/templates/tpl_modules_mobile_categories_tabs.php) called at [/home ...emplates/westminster_new/common/tpl_header.php:121]

line 58 from catefories_ul_generator.php is: $result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
line 85 from categories_ul_generator.php is: return $this->buildBranch($this->root_category_id, '', $submenu);
line 122 from tpl_modules_mobile_categories_tabs is: $menulist = $zen_CategoriesUL->buildTree(true);

3 Feb 2018, 2:16 PM
#2
lat9 avatar

lat9

Administrator

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

Re: A non-numeric value ?

Ang_l:

Hi,
I upgrade to 1.5.5f, but i think the error is comming after i change PHP Version to 7.1
that is from MyDEBUG fail :

PHP Warning: A non-numeric value encountered in /home/ga.....m/includes/classes/categories_ul_generator.php on line 58
zen_categories_ul_generator->buildBranch() called at [/h ... ludes/classes/categories_ul_generator.php:85]
zen_categories_ul_generator->buildTree() called at [/ho ... /includes/templates/westminster_new/templates/tpl_modules_mobile_categories_tabs.php:122]
require(/hom... /includes/templates/westminster_new/templates/tpl_modules_mobile_categories_tabs.php) called at [/home ...emplates/westminster_new/common/tpl_header.php:121]

line 58 from catefories_ul_generator.php is: $result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
line 85 from categories_ul_generator.php is: return $this->buildBranch($this->root_category_id, '', $submenu);
line 122 from tpl_modules_mobile_categories_tabs is: $menulist = $zen_CategoriesUL->buildTree(true);
This issue has been corrected for the (in-progress) Zen Cart 1.5.6 release by the following insertion into /includes/classes/categories_ul_generator.php's BuildBranch function:

function buildBranch($parent_id, $level = 0, $submenu=true, $parent_link='')
 {
        [B] $level = (int)$level;[/B]
         $result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
         
         if (($this->data[$parent_id])) {
3 Feb 2018, 6:51 PM
#3
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,970
Plugin Contributions:
8

Re: A non-numeric value ?

my experience with later versions of php7 require the casting back to a string.

function buildBranch($parent_id, $level = 0, $submenu=true, $parent_link='')
 {
         $level = (int)$level;
         $result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. (string)($level+1) . '"' : '' );
         
         if (($this->data[$parent_id])) {

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

3 Feb 2018, 6:57 PM
#4
lat9 avatar

lat9

Administrator

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

Re: A non-numeric value ?

carlwhat:

my experience with later versions of php7 require the casting back to a string.

function buildBranch($parent_id, $level = 0, $submenu=true, $parent_link='')
{
$level = (int)$level;
$result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. COLOR=red/COLOR . '"' : '' );

     if (($this->data[$parent_id])) {
You should submit a PR, then, since the code I posted is the current version on the Zen Cart v156 GitHub.
4 Feb 2018, 1:17 AM
#5
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,970
Plugin Contributions:
8

Re: A non-numeric value ?

my mistake... i am not able to replicate the error using php7.1 or php7.2.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

5 Feb 2018, 8:31 AM
#6
ang_l avatar

ang_l

New Zenner

Join Date:
Jan 2017
Location:
Bulgaria
Posts:
11
Plugin Contributions:
0

Re: A non-numeric value ?

Thank you!
After i find this
https://www.zen-cart.com/showthread.php?222638-PHP-Warning-A-non-numeric-value-encountered-PHP-7-warnings
i changed categories_ul_generator.php with ...el'. (float)($level+1) . '"... that is correct? Or must change again with (string)?

Now i changed and /includes/modules/pages/advanced_search_result/header_php.php:
$rate = $currencies->get_value($_SESSION['currency']);
if ($rate) {
$pfrom = (float)$_GET['pfrom'] / $rate;
$pto = (float)$_GET['pto'] / $rate;
}

5 Feb 2018, 12:59 PM
#7
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,970
Plugin Contributions:
8

Re: A non-numeric value ?

no need to add string.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

5 Feb 2018, 4:26 PM
#8
ang_l avatar

ang_l

New Zenner

Join Date:
Jan 2017
Location:
Bulgaria
Posts:
11
Plugin Contributions:
0

Re: A non-numeric value ?

Thank you!