Zen Cart Logo
Forums / General Questions / Warning and deprecated messages for CSS Flyout menu

Warning and deprecated messages for CSS Flyout menu

Views: 1,030

Results 1 to 6 of 6
15 Apr 2021, 5:40 AM
#1
joseph_m avatar

joseph_m

Zen Follower

Join Date:
Apr 2008
Posts:
150
Plugin Contributions:
0

Warning and deprecated messages for CSS Flyout menu

I'm using v157c with Bootstrap template. The CSS Flyout Menu (found here https://www.zen-cart.com/downloads.php?do=file&id=1) installed well on my site, and seems to function well on the user end. But my logs are getting filled with warnings every time a page is called.

--> PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; zen_categories_ul_generator has a deprecated constructor
I know it's a pretty old plugin, but I'd like to use it. Is there an update or a relatively easy way to fix that? Thank you.

15 Apr 2021, 6:01 AM
#2
carlwhat avatar

carlwhat

zennedOut

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

Re: Warning and deprecated messages for CSS Flyout menu

Joseph M:

I'm using v157c with Bootstrap template. The CSS Flyout Menu (found here https://www.zen-cart.com/downloads.php?do=file&id=1) installed well on my site, and seems to function well on the user end. But my logs are getting filled with warnings every time a page is called.

I know it's a pretty old plugin, but I'd like to use it. Is there an update or a relatively easy way to fix that? Thank you.

try changing line 44 of:

includes/classes/categories_ul_generator.php

//from:
function zen_categories_ul_generator($load_from_database = true) {
to:
function __construct($load_from_database = true) {

best.

16 Apr 2021, 1:47 AM
#3
joseph_m avatar

joseph_m

Zen Follower

Join Date:
Apr 2008
Posts:
150
Plugin Contributions:
0

Re: Warning and deprecated messages for CSS Flyout menu

carlwhat:

try changing line 44 of:

includes/classes/categories_ul_generator.php

//from:
function zen_categories_ul_generator($load_from_database = true) {
to:
function __construct($load_from_database = true) {

> 
> best.

Worked perfectly.  That eliminated the deprecated log warning.  Thank you.  I am still getting > A non-numeric value encountered in log warning for lines 68 and 100 that I'm trying to make sense of.  There were a couple of solutions suggested at <https://www.zen-cart.com/showthread.php?222638-Done-v1-5-6-PHP-Warning-A-non-numeric-value-encountered-PHP-7-warnings> but neither has solved the problem.
16 Apr 2021, 4:53 AM
#4
carlwhat avatar

carlwhat

zennedOut

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

Re: Warning and deprecated messages for CSS Flyout menu

Joseph M:

Worked perfectly. That eliminated the deprecated log warning. Thank you. I am still getting log warning for lines 68 and 100 that I'm trying to make sense of. There were a couple of solutions suggested at https://www.zen-cart.com/showthread.php?222638-Done-v1-5-6-PHP-Warning-A-non-numeric-value-encountered-PHP-7-warnings but neither has solved the problem.

the problem deals with php7 and more strict typing of vars. i think if you to the following change on lines 67 and 68, you should be good.

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

best.

17 Apr 2021, 1:00 AM
#5
joseph_m avatar

joseph_m

Zen Follower

Join Date:
Apr 2008
Posts:
150
Plugin Contributions:
0

Re: Warning and deprecated messages for CSS Flyout menu

carlwhat:

the problem deals with php7 and more strict typing of vars. i think if you to the following change on lines 67 and 68, you should be good.

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

> 
> best.

Right on target again, carlwhat.  The site is running the plugin with no warning logs.  I'd venture to say that with the two fixes you offered above, you've updated it for v157c.

Is there a (hopefully simple) way to tell it to exclude categories with a specific category_id?  I have it set up to exclude empty categories, but there are some that I don't want the menu to show at all.
17 Apr 2021, 1:22 AM
#6
carlwhat avatar

carlwhat

zennedOut

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

Re: Warning and deprecated messages for CSS Flyout menu

Joseph M:

Right on target again, carlwhat. The site is running the plugin with no warning logs. I'd venture to say that with the two fixes you offered above, you've updated it for v157c.

Is there a (hopefully simple) way to tell it to exclude categories with a specific category_id? I have it set up to exclude empty categories, but there are some that I don't want the menu to show at all.

with regards to your question, as i tell all my clients, given enough time and money, anything is possible... :smile:

you bring up a couple of interesting points here. i'm not that familiar with the flyout menu plugin, but it makes use of the categories_ul_generator class, which it has packaged in the plugin. but that class is part of the base ZC package which has the changes that i have provided to you. but how that class in the plugin is different from the class packaged with ZC... well you got me.... a diff certainly shows differences, but whether the base class will work with the plugin, i do not know...

but an interesting issue (at least to me) is the stamping of the class as seen here:

https://github.com/zencart/zencart/blob/v157/includes/classes/categories_ul_generator.php

the timestamp from @DrByte says almost 17 years ago; and yet there have been changes made as little as 3 years ago with no corresponding change in the time stamp in the header comments.

i know the methodology for changing those stamps has changed over the years; and at 1 point i got into a conversation with the team about it. now, i try now to worry about it; but it does seem like this time stamp is blatantly askew as the class packaged with the plugin has a similar date, but yet has not addressed some very basic changes in php that have evolved over the years.

best.