Zen Cart Logo
Forums / Basic Configuration / Duplicate Mysql query

Duplicate Mysql query

Locked

Views: 2,804

Results 1 to 20 of 21
This thread is locked. New replies are disabled.
23 Jul 2016, 8:16 PM
#1
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Duplicate Mysql query

There appears to be a duplicate Mysql query executing with same field in the primary key I am not sure what is causing this problem, I have recently upgraged the site from 1.5.3 to 1.5.5a and I have recently installed the responsive theme sheffield blue ... so lots of potential for where the problem might be I guess. Here is the exact problem being logged by zencart admin.

PHP Fatal error: 1062: Duplicate entry 'zc_6f04dac868865df99eb25f13ecae29f6' for key 'PRIMARY' :: insert into cabdb_cache set cache_entry_name = 'zc_6f04dac868865df99eb25f13ecae29f6'

This happens lots of times by the way, hope somebody can help, thanks.

I am also getting a parse error
PHP Parse error: syntax error, unexpected $end in /public_html/includes/languages/english/schneiderstyle/time_out.php on line 19 - that (schneiderstyle) is in an older override folder I no longer use .... again any thoughts gratefully appreciated.

23 Jul 2016, 8:25 PM
#2
lat9 avatar

lat9

Administrator

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

Re: Duplicate Mysql query

When you did your upgrade, did you pick up the change to /includes/classes/cache.php? In an as-shipped Zen Cart 1.5.5a file-set, there's no INSERT INTO the cache database table; it's been updated to an INSERT IGNORE INTO.

23 Jul 2016, 8:26 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Duplicate Mysql query

That issue of the duplicate key was resolved definitely in ZC 1.5.5 and I thought sooner (it at least made one of the known bugs list for one of the recent earlier versions.)

Suggest double checking the upgrade (how was it performed?).

As to the "random" override, either something else is purposefully loading that file or the template is considered active in your tools->template selection area. Or possibly the database entries in your configure.php files are incorrect (make sure that your DB_PREFIX is the same in both includes/configure.php and admin/includes/configure.php as well matches the same in your files of the store before upgrade.

23 Jul 2016, 8:36 PM
#4
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

Hi lat9,
thanks for the quick response, here is what my current cache.php states
$sql = "insert ignore into " . TABLE_DB_CACHE . " (cache_entry_name, cache_data, cache_entry_created) VALUES (:cachename, :cachedata, unix_timestamp() )";

So I think that is how it should be if I understand you correctly.

23 Jul 2016, 8:40 PM
#5
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

mc12345678:

That issue of the duplicate key was resolved definitely in ZC 1.5.5 and I thought sooner (it at least made one of the known bugs list for one of the recent earlier versions.)

Suggest double checking the upgrade (how was it performed?).

As to the "random" override, either something else is purposefully loading that file or the template is considered active in your tools->template selection area. Or possibly the database entries in your configure.php files are incorrect (make sure that your DB_PREFIX is the same in both includes/configure.php and admin/includes/configure.php as well matches the same in your files of the store before upgrade.

This is a difficult one to answer MC ... I upgraded to the best of my ability .... and followed the instructions as much as possible, I could have made a mistake anywhere along the way ... and likely probably did ... could you help me narrow it down, where would you begin to look for the duplicate key error?

Will check through your suggestions for the override, thanks.

23 Jul 2016, 9:40 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Duplicate Mysql query

Pauls:

This is a difficult one to answer MC ... I upgraded to the best of my ability .... and followed the instructions as much as possible, I could have made a mistake anywhere along the way ... and likely probably did ... could you help me narrow it down, where would you begin to look for the duplicate key error?

Will check through your suggestions for the override, thanks.
Well, "from here" it would help to know which instructions. And even with that, did you load a complete fileset of the latest 1.5.5a to somewhere on your server (not overwriting the existing store), and then incorporate differences from your previous store, or did you copy all of the stores files and then incorporate the differences from ZC 1.5.5a into it? That type of thing.

I would however, suggest looking into the configure.php files as the primary suspicion. Wondering if they in part refeerence to the old store location that is still there and perhaps old data in the database that has gotten upgraded.

23 Jul 2016, 10:06 PM
#7
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

mc12345678:

Well, "from here" it would help to know which instructions. And even with that, did you load a complete fileset of the latest 1.5.5a to somewhere on your server (not overwriting the existing store), and then incorporate differences from your previous store, or did you copy all of the stores files and then incorporate the differences from ZC 1.5.5a into it? That type of thing.

I would however, suggest looking into the configure.php files as the primary suspicion. Wondering if they in part refeerence to the old store location that is still there and perhaps old data in the database that has gotten upgraded.

OK well, I uploaded the files needed for a ZC installation and followed the prompts from the ZC_install page thereafter ... this was if I recall correctly an 'upgrade' not a complete new site, which relied upon and still uses the previous 1.5.3 version database from which the site was previously running. Because you mentioned the config files I did take a look at them, and found that the 'define('SQL_CACHE_METHOD', 'database');' was set to database ... in the previous version I had that set to none ... so I have changed it in both configs includes, and admin/includes to 'none'. Not sure whether that will help but it may be relevant?

I am also getting a fair few of this error include(/public_html/includes/modules/responsive_sheffield_blue/product_listing.php) called at [/public_html/includes/templates/responsive_sheffield_blue/templates/tpl_modules_product_listing.php:
for various different pages in the template not just the one mentioned there ...

And this which I believe is not a template file but a zencart file, a fair few of these errors too.
PHP Fatal error: 1109:Unknown table 'p' in field list :: select count(p.products_id) as total ==> (as called by) public_html/includes/classes/split_page_results.php on line 78 <== in /public_html/includes/classes/db/mysql/query_factory.php on line 167

regards

Paul

24 Jul 2016, 2:00 AM
#8
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Duplicate Mysql query

Okay, so first thing is to try working from your most recent error log, resolve that and then the most recent one after solving that, etc. Until no error logs are being generated.

Considering that the most recently posted logs relate to the responsive sheffield blue template, the place to start would be to look in the thread related to that template. Start from the end of the thread (a discussion related to the issues you've posted about has been had many times over and there is assistance associated to it.)

As to the configure.php files, that particular setting isn't normally expected to cause the error(s) identified.

As to the upgrade/rebuild, well, still not very clear about whether the new files were put into their own directory and other things added to them or if they were uploaded over top a copy or the original files. If the former, then other files wouldn't be "in the way", if the later (which it kind of seems like) then there are possibly files still around that were removed between ZC 1.5.3 and 1.5.5x.

One of the generally suggested instructions to perform an upgrade (which involves loading a fresh install of the files to some location/folder that is not immediately where the live site's files are and a copy of the database to do what is necessary to get the database updated, the needed plugins installed/upgraded and then repeating necessary actions against the live site. That is: http://www.zen-cart.com/entry.php?3-How-do-I-rebuild-my-site-on-the-new-version-instead-of-upgrading

24 Jul 2016, 8:47 AM
#9
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

Thanks for the advice and logic MC will give it a shot and see what develops.

24 Jul 2016, 11:44 AM
#10
lat9 avatar

lat9

Administrator

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

Re: Duplicate Mysql query

@Pauls, it would help if you would post the **full **debug-log contents. Zen Cart 1.5.5a includes the myDebug Backtrace handling that will display a backtrace (i.e. which PHP modules were in the calling sequence when the error occurred).

@mc12345678, The "duplicate key" issue that was corrected in Zen Cart 1.5.5a had to do with the *sessions *table, not the cache table.

24 Jul 2016, 2:42 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Duplicate Mysql query

lat9:

@mc12345678, The "duplicate key" issue that was corrected in Zen Cart 1.5.5a had to do with the *sessions *table, not the cache table.
Actually, both were addressed in ZC 1.5.5 (not saying specifically 1.5.5 versus 1.5.5a, but at least in that "series").

A/the solution was identified back in the middle to end of 2014 before ZC 1.5.4 was officially released. Then it was not incorporated in ZC 1.5.4, but was referenced as a bug in ZC 1.5.4 (but also backwards to other versions of ZC), which means that "officially" it wouldn't make it into the released core until the next version, dated change, or other release. In this case ZC 1.5.5ish. For me and why I couldn't recall the specifics was the pre-ZC 1.5.4 discovery and correction that didn't make it into ZC 1.5.4, but having both encountered the issue and taken part in testing of it against ZC 1.5.1, 1.5.3, and 1.5.4, well forgot the incorporation date/version, but remembered to which/where it related.

So, I'm not sure to which sessions "correction" you are referring, but of the solutions posted and existing code, I'm not visually seeing a difference in the "resolution". Maybe I need new eyes or a bigger screen. :P

24 Jul 2016, 3:52 PM
#12
lat9 avatar

lat9

Administrator

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

Re: Duplicate Mysql query

Apologies, mc12345678, I was going on the fact that the majority of the reported issues were present with the sessions table rather than the cache (although I see that both have been changed since ZC1.5.3).

@Pauls, you could use your admin's Tools->Developers Tool Kit to search for TABLE_DB_CACHE in all your store's .php files; perhaps there's a remnant of the previous handling (i.e. INSERT INTO rather than INSERT IGNORE INTO) that table.

24 Jul 2016, 7:37 PM
#13
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

lat9:

@Pauls, it would help if you would post the **full **debug-log contents. Zen Cart 1.5.5a includes the myDebug Backtrace handling that will display a backtrace (i.e. which PHP modules were in the calling sequence when the error occurred).

@mc12345678, The "duplicate key" issue that was corrected in Zen Cart 1.5.5a had to do with the *sessions *table, not the cache table.

Hi Lat9
here is a full log .. today there have been 42 such logs ... similar amount yesterday too!

[24-Jul-2016 18:53:21 Europe/] Request URI: /index.php?main_page=products_all, IP address: 188...***
#1 trigger_error() called at [/public_html/includes/classes/db/mysql/query_factory.php:167]
#2 queryFactory->show_error() called at [ /public_html/includes/classes/db/mysql/query_factory.php:139]
#3 queryFactory->set_error() called at [ /public_html/includes/classes/db/mysql/query_factory.php:266]
#4 queryFactory->Execute() called at [ /public_html/includes/classes/split_page_results.php:78]
#5 splitPageResults->__construct() called at [ /public_html/includes/modules/responsive_sheffield_blue/product_listing.php:35]
#6 include( /public_html/includes/modules/responsive_sheffield_blue/product_listing.php) called at [ /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_modules_product_listing.php:14]
#7 require( /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_modules_product_listing.php) called at [ /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_products_all_default.php:18]
#8 require( /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_products_all_default.php) called at [ /public_html/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php:251]
#9 require( /public_html/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php) called at [ /public_html/index.php:97]

[24-Jul-2016 18:53:21 Europe/London] PHP Fatal error: 1109:Unknown table 'p' in field list :: select count(p.products_id) as total ==> (as called by) /public_html/includes/classes/split_page_results.php on line 78 <== in /public_html/includes/classes/db/mysql/query_factory.php on line 167

24 Jul 2016, 7:40 PM
#14
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

lat9:

Apologies, mc12345678, I was going on the fact that the majority of the reported issues were present with the sessions table rather than the cache (although I see that both have been changed since ZC1.5.3).

@Pauls, you could use your admin's Tools->Developers Tool Kit to search for TABLE_DB_CACHE in all your store's .php files; perhaps there's a remnant of the previous handling (i.e. INSERT INTO rather than INSERT IGNORE INTO) that table.

Cheers, will give this a go right away.

/public_html/admin/includes/init_includes/init_database.php

Line #39 : $sql = "SHOW TABLES LIKE '" . TABLE_DB_CACHE . "'";

/public_html/includes/classes/cache.php

Line # 36 : $sql = "select * from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name . "'";

Line # 66 : $sql = "select * from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name ."'";

Line # 95 : $sql = "delete from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name . "'";

Line #122 : $sql = "select * from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name . "'";

Line #128 : $sql = "insert ignore into " . TABLE_DB_CACHE . " (cache_entry_name, cache_data, cache_entry_created) VALUES (:cachename, :cachedata, unix_timestamp() )";

Line #154 : $sql = "select * from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name . "'";

Line #184 : $sql = "delete from " . TABLE_DB_CACHE;

/public_html/includes/database_tables.php

Line # 45 : define('TABLE_DB_CACHE', DB_PREFIX . 'db_cache');

/public_html/includes/init_includes/init_database.php

Line #47 : $sql = "SHOW TABLES LIKE '" . TABLE_DB_CACHE . "'";

I changed the admin folder name, this was a search of 1449 files and found the 10 matches above.

25 Jul 2016, 1:48 AM
#15
drbyte avatar

drbyte

Sensei

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

Re: Duplicate Mysql query

It seems that either or both of these files are not current:
/includes/classes/cache.php
/includes/functions/sessions.php

25 Jul 2016, 8:39 AM
#16
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

DrByte:

It seems that either or both of these files are not current:
/includes/classes/cache.php
/includes/functions/sessions.php

Hi thanks for your reply, here are screenshots of a comparison between the two files, each from the original expanding zip file containing ZC1.5.5a files, the other from the server live
Attachment 16527

Attachment 16528

The sessions file had line endings that were different I have no idea why or how that could happen, nonetheless I have overwritten the sessions.php file with the one from the 1.5.5a version of zencart.

25 Jul 2016, 8:47 AM
#17
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

Pauls:

Hi thanks for your reply, here are screenshots of a comparison between the two files, each from the original expanding zip file containing ZC1.5.5a files, the other from the server live
Attachment 16527

Attachment 16528

The sessions file had line endings that were different I have no idea why or how that could happen, nonetheless I have overwritten the sessions.php file with the one from the 1.5.5a version of zencart.

RE: my last reply, I need to check something ... I will reply shortly.

Looks OK thought I had checked the wrong files, all is good .... now I will check the server for errors shortly.

25 Jul 2016, 9:00 AM
#18
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

OK here is an error in the log file, after checking after re-uploading the above two files again.

#1 trigger_error() called at [ /public_html/includes/classes/db/mysql/query_factory.php:167]
#2 queryFactory->show_error() called at [ /public_html/includes/classes/db/mysql/query_factory.php:139]
#3 queryFactory->set_error() called at [ /public_html/includes/classes/db/mysql/query_factory.php:266]
#4 queryFactory->Execute() called at [ /public_html/includes/classes/split_page_results.php:78]
#5 splitPageResults->__construct() called at [ /public_html/includes/modules/responsive_sheffield_blue/product_listing.php:35]
#6 include( /public_html/includes/modules/responsive_sheffield_blue/product_listing.php) called at [ /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_modules_product_listing.php:14]
#7 require( /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_modules_product_listing.php) called at [ /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_products_all_default.php:18]
#8 require( /public_html/includes/templates/responsive_sheffield_blue/templates/tpl_products_all_default.php) called at [ /public_html/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php:251]
#9 require( /public_html/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php) called at [ /public_html/index.php:97]

PHP Fatal error: 1109:Unknown table 'p' in field list :: select count(p.products_id) as total ==> (as called by) /public_html/includes/classes/split_page_results.php on line 78 <== in /public_html/includes/classes/db/mysql/query_factory.php on line 167

25 Jul 2016, 10:22 AM
#19
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Duplicate Mysql query

These recent errors relate to how the template was installed and in relation to its use on ZC 1.5.5... that issue is documented frequently in the forum for Responsive Sheffield Blue. I can't recall if it is because of a lack of uploading the split_page_results file from the plugin, or if because it was... there are a few notes though about incorporating that template, some if not all are identified in this thread: https://www.zen-cart.com/showthread.php?219801-Making-v154-DIY-Picaflor-Azul-templates-work-with-v1-5-5

25 Jul 2016, 11:18 AM
#20
pauls avatar

pauls

Zen Follower

Join Date:
Feb 2006
Location:
UK
Posts:
300
Plugin Contributions:
0

Re: Duplicate Mysql query

mc12345678:

These recent errors relate to how the template was installed and in relation to its use on ZC 1.5.5... that issue is documented frequently in the forum for Responsive Sheffield Blue. I can't recall if it is because of a lack of uploading the split_page_results file from the plugin, or if because it was... there are a few notes though about incorporating that template, some if not all are identified in this thread: https://www.zen-cart.com/showthread.php?219801-Making-v154-DIY-Picaflor-Azul-templates-work-with-v1-5-5

Thanks again MC I will take a look at the RSB thread again, I did look but it's massive and information there is a year old in some cases so I am not sure whether to change files or not based on someone's issue 12 months ago if you see what I mean as I would have thought those issues would have been addressed in version 2.0 of the theme.

I don't want to give up on the RSB theme as it looks and works fab.

The thread you posted looks like it has potential, thanks I will have a scan through and try a few suggestions.