Zen Cart Logo
Forums / Customization from the Admin / Parameter ordering changed on zen_get_show_product_switch ... how come?

Parameter ordering changed on zen_get_show_product_switch ... how come?

Views: 1,376

Results 1 to 9 of 9
17 May 2016, 3:20 PM
#1
lat9 avatar

lat9

Administrator

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

Parameter ordering changed on zen_get_show_product_switch ... how come?

The ordering for the $prefix and $suffix parameters to zen_get_show_product_switch and zen_get_show_product_switch_name changed going from Zen Cart 1.5.4 to 1.5.5, introducing an incompatibility for any plugin that's using one of those functions (or distributing a modified version of the admin general.php function file).:censored:

I'm hoping that there was a **really **good reason...

17 May 2016, 4:02 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

lat9:

The ordering for the $prefix and $suffix parameters to zen_get_show_product_switch and zen_get_show_product_switch_name changed going from Zen Cart 1.5.4 to 1.5.5, introducing an incompatibility for any plugin that's using one of those functions (or distributing a modified version of the admin general.php function file).:censored:

I'm hoping that there was a **really **good reason...

Yeah to have the values show grammatically correct.

There was no change in functionality and the values posted/pushed are truly the same order. But A is not a suffix to B in the following sequence just like C is not a prefix to B:

ABC

In the previous code, A was identified as a suffix to B.. Now A is actually the prefix to B and the sequence of data is no different.

See the ZC 154 version (shortened to show the "issue"):

    function zen_get_show_product_switch_name($lookup, $field, $suffix= 'SHOW_', $prefix= '_INFO', $field_prefix= '_', $field_suffix='') { 
 /* code removed from between to show how the "suffix" and "prefix" are actually used... */
      $zv_key = strtoupper($suffix . $type_handler . $prefix . $field_prefix . $field . $field_suffix); 

Now see the ZC 155 version (also shortened to show... THAT THERE IS NO CHANGE):

    function zen_get_show_product_switch_name($lookup, $field, $prefix= 'SHOW_', $suffix= '_INFO', $field_prefix= '_', $field_suffix='') { 
 /* Now note how $prefix is a prefix and $suffix is a suffix, and note how the sequence has not changed... The value(s) remain the same and are used correctly. */
      $zv_key = strtoupper($prefix . $type_handler . $suffix . $field_prefix . $field . $field_suffix); 

Now, go take a look at this updated "help" page and see if you would have known what data to populate in order for the function to provide the desired result if the prefix and suffix had not been swapped?

17 May 2016, 4:11 PM
#3
lat9 avatar

lat9

Administrator

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

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

Do you have any idea the amount of extra work that you've created for me (and possibly other plugin contributors) to correct a non-issue?

So what if the parameters didn't seem "in the right order"? The "wrong" parameter order had been working just fine since at least Zen Cart 1.3.5.

Now I'm faced with a slew of plugins that distribute that function file with a couple of changes that will either work on Zen Cart 1.5.5 or on earlier versions. I am not currently a happy-camper.:yuck:

17 May 2016, 4:22 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

lat9:

Do you have any idea the amount of extra work that you've created for me (and possibly other plugin contributors) to correct a non-issue?

So what if the parameters didn't seem "in the right order"? The "wrong" parameter order had been working just fine since at least Zen Cart 1.3.5.

Now I'm faced with a slew of plugins that distribute that function file with a couple of changes that will either work on Zen Cart 1.5.5 or on earlier versions. I am not currently a happy-camper.:yuck:

So you're saying that within each of those functions you modified the code to use the $suffix and $prefix variables as they were written? Getting into and out of the functions did not change. There's nothing preventing you from continuing to distribute the code with the variable name still switched. They serve the same function and operation.

It was an error seen and exacerbated when trying to actually use the code as written and the reference(s) provided. To actually determine what had to be sent required reviewing the remainder of the code not (yet?) available at that resource intended to replace this one. Just because it has existed doesn't mean it should remain wrong. Not the right answer.

17 May 2016, 4:55 PM
#5
lat9 avatar

lat9

Administrator

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

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

No, what I'm saying is that I (and others) have plugin distributions that include a modified copy of the general.php file ... that used to be downwardly compatible from 1.5.4 through (at least) 1.5.1.

Now, my plugins' distributions have to be modified to somehow deal with two different versions of the general.php file, for no reason other than the order of those parameters "didn't look right".

In the future, please pay attention to the fact that those function files (and classes) are used by code outside of the Zen Cart base distribution and don't willy-nilly make changes that change the calling-sequence of the built-in handling. What you should have done was to create a new function that had the parameter-order the way that you wanted and leave the existing function as-is.

17 May 2016, 5:10 PM
#6
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

lat9:

What you should have done was to create a new function that had the parameter-order the way that you wanted and leave the existing function as-is.

Totally Agree.

17 May 2016, 5:43 PM
#7
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

Forrest... meet trees...

What you provided to that function by any outside code is still the same now as it was....

There is 0 difference in the "sequence". The difference is now instead of thinking oh this is that function that says suffix but what I really am providing is the prefix...

There is absolutely no change in using the functions...

By saying that you didn't use the $prefix or $suffix variables within the two functions, you've only further explained that there is no effect in any of your code...

Notice. The position of the variables where they are used has not changed. Follow the colors in the above code snippets... red is still in the same position top to bottom. Blue is still in the same position. Zip, zero, zilch difference in operation. They were though wrong.

17 May 2016, 5:53 PM
#8
drbyte avatar

drbyte

Sensei

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

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

mc12345678:

What you provided to that function by any outside code is still the same now as it was....

There is 0 difference in the "sequence". The difference is now instead of thinking oh this is that function that says suffix but what I really am providing is the prefix...

There is absolutely no change in using the functions...

By saying that you didn't use the $prefix or $suffix variables within the two functions, you've only further explained that there is no effect in any of your code...

Notice. The position of the variables where they are used has not changed. Follow the colors in the above code snippets... red is still in the same position top to bottom. Blue is still in the same position. Zip, zero, zilch difference in operation. They were though wrong.
Agreed. It's still backwardly compatible. The variable names in the function could be $fred and $mary instead of $prefix and $suffix, and would make no difference externally.

17 May 2016, 6:18 PM
#9
lat9 avatar

lat9

Administrator

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

Re: Parameter ordering changed on zen_get_show_product_switch ... how come?

My apologies. I'd seen the reversed argument-names on the function and ######-u-me'd that the payload had been reversed as well.