Jump to content

Integrity constraint violation ...sometimes


joe_g
 Share

Recommended Posts

HI there,

I'm getting this error on the bottom of a page. If I save the page in the backend, it's gone – only to be back again after clicking around in the site. I'm not sure how to start debugging it, since I can't see where it comes from really.

In the source it appears after the last DIV, so its after all page code is executed. It only seem to happen locally, and not on the live site, luckily. it happens on both staging and local. This same error has been appearing in various pages, but usually it goes away after saving, but finally it started happening repeatedly on one of the pages.

I'm looking for clues on where this might come from, or how to find out. Thanks,

J

Error: Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'basicpage' for key 'name' (in /Applications/MAMP/htdocs/website/wire/core/WireSaveableItems.php line 210)

#0 /Applications/MAMP/htdocs/website/wire/core/WireSaveableItems.php(210): PDOStatement->execute()
#1 /Applications/MAMP/htdocs/website/wire/core/Templates.php(159): WireSaveableItems->___save(Object(Template))
#2 [internal function]: Templates->___save(Object(Template))
#3 /Applications/MAMP/htdocs/website/wire/core/Wire.php(389): call_user_func_array(Array, Array)
#4 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('save', Array)
#5 /Applications/MAMP/htdocs/website/wire/core/Template.php(509): Wire->__call('save', Array)
#6 /Applications/MAMP/htdocs/website/wire/core/Template.php(509): Templates->save(Object(Template))
#7 /Applications/MAMP/htdocs/website/wire/core/Template.php(554): Template->save()
#8 /Applications/MAMP/htdocs/website/wire/core/Wire.php(411): Template->hookFin
This error message was shown because site is in debug mode ($config->debug = true; in /site/config.php). Error has been logged.
Link to comment
Share on other sites

  • 2 weeks later...

Hello again,

I'm a bit stuck on this issue. It seems to me it's something behind the scenes going on.

1. I edit my-template.php (Like, comment or uncomment some line of php)

2. Viewing the page that is using my-template I get the above error added after all regular markup

3. I hit save on the my-template page

4. error is gone

5. If i change anything in my-template.php error is back 

..repeat

The error complains about 'basicpage' which is a template that has nothing to do with the page I'm working on at the moment.

any hints or guesses would me most helpful,

(PW version 2.5.3)

thanks

J

Link to comment
Share on other sites

Yes, thank you. It's a good hint, 

I'm currently not really doing anything with the template basicpage. The error is unrelated to the template I'm working on, as far as I can tell

If I rename basicpage to basicpage2, I suddenly have both basicpage and basicpage2

Then, strangeness:

After that the 'new' basicpage is totally empty (even no title) with the fieldgroup from the template formerly-known-as search. I deleted the new mysterious basicpage and renamed basicpage2. Search has become basicpage, but after deleting both basicpage and search I cannot add search again - the name is taken but not listed in the templates list

confused!

Link to comment
Share on other sites

The error I get when trying to re-add search is a wall of red text:

There must be some inconsistency between the templates listed in the backend and what's really stored in the DB somehow

 TemplateFile: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'search' for key 'name'<pre>#0 /Applications/MAMP/htdocs/website/wire/core/WireSaveableItems.php(215): PDOStatement->execute() #1 /Applications/MAMP/htdocs/website/wire/core/WireSaveableItemsLookup.php(137): WireSaveableItems->___save(Object(Fieldgroup)) #2 /Applications/MAMP/htdocs/website/wire/core/Fieldgroups.php(216): WireSaveableItemsLookup->___save(Object(Fieldgroup)) #3 [internal function]: Fieldgroups->___save(Object(Fieldgroup)) #4 /Applications/MAMP/htdocs/website/wire/core/Wire.php(389): call_user_func_array(Array, Array) #5 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('save', Array) #6 /Applications/MAMP/htdocs/website/wire/core/Fieldgroup.php(318): Wire->__call('save', Array) #7 /Applications/MAMP/htdocs/website/wire/core/Fieldgroup.php(318): Fieldgroups->save(Object(Fieldgroup)) #8 /Applications/MAMP/htdocs/website/wire/modules/Process/ProcessTemplate/ProcessTemplate.module(439): Fieldgroup->save() #9 [internal function]: ProcessTemplate->___executeAdd() #10 /Applications/MAMP/htdocs/website/wire/core/Wire.php(389): call_user_func_array(Array, Array) #11 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('executeAdd', Array) #12 /Applications/MAMP/htdocs/website/wire/core/ProcessController.php(204): Wire->__call('executeAdd', Array) #13 /Applications/MAMP/htdocs/website/wire/core/ProcessController.php(204): ProcessTemplate->executeAdd() #14 [internal function]: ProcessController->___execute() #15 /Applications/MAMP/htdocs/website/wire/core/Wire.php(389): call_user_func_array(Array, Array) #16 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('execute', Array) #17 /Applications/MAMP/htdocs/website/wire/core/admin.php(85): Wire->__call('execute', Array) #18 /Applications/MAMP/htdocs/website/wire/core/admin.php(85): ProcessController->execute() #19 /Applications/MAMP/htdocs/website/site/modules/AdminTheme/AdminThemeBeurs/controller.php(13): require('/Applications/M...') #20 /Applications/MAMP/htdocs/website/site/templates/admin.php(54): require('/Applications/M...') #21 /Applications/MAMP/htdocs/website/wire/core/TemplateFile.php(169): require('/Applications/M...') #22 [internal function]: TemplateFile->___render() #23 /Applications/MAMP/htdocs/website/wire/core/Wire.php(389): call_user_func_array(Array, Array) #24 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('render', Array) #25 /Applications/MAMP/htdocs/website/wire/modules/PageRender.module(356): Wire->__call('render', Array) #26 /Applications/MAMP/htdocs/website/wire/modules/PageRender.module(356): TemplateFile->render() #27 [internal function]: PageRender->___renderPage(Object(HookEvent)) #28 /Applications/MAMP/htdocs/website/wire/core/Wire.php(389): call_user_func_array(Array, Array) #29 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('renderPage', Array) #30 /Applications/MAMP/htdocs/website/wire/core/Wire.php(411): Wire->__call('renderPage', Array) #31 /Applications/MAMP/htdocs/website/wire/core/Wire.php(411): PageRender->renderPage(Object(HookEvent)) #32 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('render', Array) #33 /Applications/MAMP/htdocs/website/wire/modules/Process/ProcessPageView.module(171): Wire->__call('render', Array) #34 /Applications/MAMP/htdocs/website/wire/modules/Process/ProcessPageView.module(171): Page->render() #35 [internal function]: ProcessPageView->___execute(true) #36 /Applications/MAMP/htdocs/website/wire/core/Wire.php(389): call_user_func_array(Array, Array) #37 /Applications/MAMP/htdocs/website/wire/core/Wire.php(344): Wire->runHooks('execute', Array) #38 /Applications/MAMP/htdocs/website/index.php(214): Wire->__call('execute', Array) #39 /Applications/MAMP/htdocs/website/index.php(214): ProcessPageView->execute(true) #40 {main}</pre>
Link to comment
Share on other sites

It's strange that the error of basicpage now switched over to search. So either there was something messed up already, but the error on basicpage stopped the script, before the one of search would be displayed. The other variant would be, that something is messing things up while processwire is loading. Could be a module, could be some of your code. Did you ever do something with the templates from the api?

Link to comment
Share on other sites

ooh, I found the error – it's really embarrassing. But I wouldn't have found it without your help.

Because the error appeared after my code, I was convinced it had to with the cms rather my stuff.

Anyway, what I did was the rookie mistake:

if($page->template->name='basicpage') {
 
instead of 
 
if($page->template->name=='basicpage') {
 
many many thanks
J
 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...