Forums / Bug Reports / sqlpatch.php help-text gives "bad" information

sqlpatch.php help-text gives "bad" information

Started by lat9 on 14 Jul 2012, 7:23 PM · Views: 779

Results 1 to 5 of 5
14 Jul 2012, 7:23 PM
#1
lat9 avatar

lat9

Administrator

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

sqlpatch.php help-text gives "bad" information

Looking through the help-text (by pressing the Details button) for the admin Tools->Install SQL Patches, the first example under "Advanced Methods" specifies the following code block as a guideline:

#NEXT_X_ROWS_AS_ONE_COMMAND:4
SET @t1=0;
SELECT (@t1:=configuration_value) as t1
FROM configuration
WHERE configuration_key = 'KEY_NAME_HERE';
UPDATE product_type_layout SET configuration_value = @t1 WHERE configuration_key = 'KEY_NAME_TO_CHECK_HERE';
DELETE FROM configuration WHERE configuration_key = 'KEY_NAME_HERE';

The SQL fragment highlighted above in red was previously identified by swguy as problematic (http://www.zen-cart.com/showthread.php?184566-1-5-modders-doing-SQL-changes-please-note!) and the source of the "Attribute Required for Text flag not working" issue. As such, the help text should be modified to give the correct usage.

P.S. It would "help" to have the "Details" button renamed to "Help" ...

16 Jul 2012, 3:51 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: sqlpatch.php help-text gives "bad" information

The point of the example wasn't the actual SQL at all. It was the use of the "#NEXT_X_ROWS_AS_ONE_COMMAND:4" which tells the script to treat the next 4 lines as one submitted statement, instead of splitting them all up after each ending semicolon.

The actual SQL in the example has no direct affect on attributes in any way.

We'll consider a different example in a future release.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jul 2012, 3:19 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: sqlpatch.php help-text gives "bad" information

Further investigation reveals that perhaps the post you quoted from swguy is incorrect.

Running the following code (even without the #NEXT_X_ROWS... instruction) works just fine, thus suggesting that there's nothing wrong with the SQL:```
SET SET @t4=0;
SELECT (@t4:=configuration_group_id) as t4 FROM configuration_group WHERE configuration_group_title= 'Images';
UPDATE configuration set configuration_value=@t4 where configuration_key = 'STORE_NAME';
UPDATE configuration set configuration_value=@t4 where configuration_key = 'STORE_OWNER';

(this will set Admin->Configuration->My Store-> store name and store owner to '4'.  Naturally you'll want to fix those to their correct values if you run this test.)

So, I must ask: have you actually tested the examples and found a specific problem?  Or are you merely pointing out a discrepancy between swguy's suggestion vs the help text provided within Zen Cart?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jul 2012, 10:48 AM
#4
swguy avatar

swguy

Administrator

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

Re: sqlpatch.php help-text gives "bad" information

@lat9: The issue, which is described more fully in http://www.zen-cart.com/showthread.php?170483-Attribute-Required-for-Text-flag-not-working&p=993178#post993178 is not that the use of this statement is problematic:

SET @t1=0;

It's the use of delete without checking the configuration group id. If you use

DELETE FROM configuration WHERE configuration_group_id = @t4 AND configuration_group_id !=0;
DELETE FROM configuration_group WHERE configuration_group_id = @t4 AND configuration_group_id !=0;

Then you'll be fine.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

18 Jul 2012, 5:58 PM
#5
lat9 avatar

lat9

Administrator

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

Re: sqlpatch.php help-text gives "bad" information

Thanks for the clarification, swguy ... MySQL is (obviously) not one of my fortes.

As far as this bug-report goes, I believe that the updated example should read:

#NEXT_X_ROWS_AS_ONE_COMMAND:4
SET @t1=0;
SELECT (@t1:=configuration_value) as t1
FROM configuration
WHERE configuration_key = 'KEY_NAME_HERE';
UPDATE product_type_layout SET configuration_value = @t1 WHERE configuration_key = 'KEY_NAME_TO_CHECK_HERE' AND t1 !=0;
DELETE FROM configuration WHERE configuration_key = 'KEY_NAME_HERE' AND t1 !=0;