Zen Cart Logo
Forums / Bug Reports / v156a Delete Product From Category Error

v156a Delete Product From Category Error

Views: 5,643

Results 1 to 10 of 10
21 Jan 2019, 10:33 AM
#1
waynestephens avatar

waynestephens

New Zenner

Join Date:
Aug 2009
Posts:
48
Plugin Contributions:
0

v156a Delete Product From Category Error

Since upgrading to v156a, when I try to delete a product from a category (when the product is present in multiple categories), the list of categories with tick boxes on the right side has an error. The first category in the list, is displayed again next to the second category, like so:

Italian Murano Glass > Murano Sommerso
Italian Murano Glass > Murano SommersoItalian Murano Glass > Murano Faceted

Where it should be:

Italian Murano Glass > Murano Sommerso
Italian Murano Glass > Murano Faceted

When I open the file: admin/category_product_listing.php I am told it has a syntax error on line 155. This file has not been edited and is not affected by any plugins. The area of code is as follows:

154 $cascaded_prod_id_for_delete = $category_product['products_id'];
155 $cascaded_prod_cat_for_delete = [];
156 $cascaded_prod_cat_for_delete[] = $categories[$i]['id'];

I am using php version 7.3. Changing the version back to 7.0 seems to have no effect on the error.

21 Jan 2019, 1:27 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: v156a Delete Product From Category Error

Can't repro in PHP 7.2.13. Please try changing line 155 from

$cascaded_prod_cat_for_delete = [];

to

$cascaded_prod_cat_for_delete = array();

21 Jan 2019, 2:09 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: v156a Delete Product From Category Error

I had seen this issue, but hadn't documented the occurrence so couldn't exactly remember how to replicate but yes there was a display issue associated with linked product and selecting one of the actions where normally expected to place a check mark for the one(s) to keep or delete depending on the action.

21 Jan 2019, 2:30 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: v156a Delete Product From Category Error

Looking again I see the display issue now (but not the error).

PR: https://github.com/zencart/zencart/pull/2109

21 Jan 2019, 2:30 PM
#5
waynestephens avatar

waynestephens

New Zenner

Join Date:
Aug 2009
Posts:
48
Plugin Contributions:
0

Re: v156a Delete Product From Category Error

swguy:

Can't repro in PHP 7.2.13. Please try changing line 155 from

$cascaded_prod_cat_for_delete = [];

to

$cascaded_prod_cat_for_delete = array();

Tried this, doesn't seem to have made any difference, apart from the syntax error warning went away, but I got another instead for line 1019:

1018 <?php
1019 $heading = [];
1020 $contents = [];

21 Jan 2019, 2:37 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: v156a Delete Product From Category Error

WayneStephens:

Tried this, doesn't seem to have made any difference, apart from the syntax error warning went away, but I got another instead for line 1019:

1018 <?php
1019 $heading = [];
1020 $contents = [];

Yes, this is the same issue.

21 Jan 2019, 4:04 PM
#7
waynestephens avatar

waynestephens

New Zenner

Join Date:
Aug 2009
Posts:
48
Plugin Contributions:
0

Re: v156a Delete Product From Category Error

Thanks for fix on GitHub, working fine now :smile:

22 Jan 2019, 7:51 PM
#8
drbyte avatar

drbyte

Sensei

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

Re: v156a Delete Product From Category Error

@WayneStephens,

I think that the syntax-error warnings you're getting in your code-editor application are a result of your code editor not being set to expect newer PHP version syntax.
Those lines you quoted would indeed be bad for PHP 5.2, but are fine for newer PHP versions (and indeed expected).

22 Jan 2019, 7:53 PM
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: v156a Delete Product From Category Error

LOL that didn't even occur to me. I was wondering why I couldn't find a switch to disable short array syntax.

23 Jan 2019, 9:25 AM
#10
waynestephens avatar

waynestephens

New Zenner

Join Date:
Aug 2009
Posts:
48
Plugin Contributions:
0

Re: v156a Delete Product From Category Error

DrByte:

@WayneStephens,

I think that the syntax-error warnings you're getting in your code-editor application are a result of your code editor not being set to expect newer PHP version syntax.
Those lines you quoted would indeed be bad for PHP 5.2, but are fine for newer PHP versions (and indeed expected).

Ah sorry I should have thought of that, makes sense, the program is a couple of years old, thanks!