Trying to edit a Bean type to include a description (was previously empty)
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1572 of /*********/includes/bootstrap.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'beantype_name' for key 2: INSERT INTO {bean_type} (name, label, description) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => ******_sponsor [:db_insert_placeholder_1] => ******* - Sponsor [:db_insert_placeholder_2] => save ) in drupal_write_record() (line 6975 of /*********/includes/common.inc).
Marked as Major because it's not possible to save the edited bean-type.
The Description was empty, yielding this other minor error #1452368, that's why I was trying to edit it. Maybe that condition has to do with this particular failure? I don't know.
Comments
Comment #0.0
beanluc commentedDescribing conditions
Comment #1
indytechcook commentedIs this still an issue since that code has been commttted?
Comment #2
beanluc commentedWho knows. Now I can't even load the bean types page:
PHP Fatal error: Call to undefined function block_custom_get_types() in /*********/sites/all/modules/bean/bean_admin_ui/bean_admin_ui.admin.inc on line 16Comment #3
beanluc commentedThis fixes the whitescreen. Now I'll check the actual issue here.
Comment #4
beanluc commentedNo, this didn't help at all. Now I get the generic message "The website encountered an unexpected error" when trying to save a bean-type. There aren't any PHP errors visible on the page or the phperrors.log file. This is on a development site so I would ordinarily expect to be able to see error messages in one or the other or both of those places.
Comment #5
beanluc commentedComment #6
beanluc commentedOK, I did tweak error reporting settings a bit, and I was able to get
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '*****_sponsor' for key 'name': INSERT INTO {bean_type} (name, label, description) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => *****_sponsor [:db_insert_placeholder_1] => ***** - Sponsor [:db_insert_placeholder_2] => This block-type is for individual sponsor ads in the "Ad" block-regions (on homepage, category landing pages and Article pages). ) in drupal_write_record() (line 6975 of /*********/htdocs/includes/common.inc).That's a little different from the original reported error, but, this issue would seem to not be closely related to the fix for #1452368.
Comment #8
indytechcook commentedSorry about that. I reverted that change. I was working on block entities in D8 and was making changes in the wrong window.
I just rolled rc3 which should be available soon
Comment #9
beanluc commentedrc3 hasn't helped matters at all. Not that I expected it to - as noted in #3 and #4 above. I'm just making a point of reporting back on rc3 so that it's clear that no progress has been made.
Editing and saving an existing bean-type (for the sake of filling an empty Description) continues to yield the same exact error as ever:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '**_homepage_guide' for key 'name': INSERT INTO {bean_type} (name, label, description) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => **_homepage_guide [:db_insert_placeholder_1] => *** Homepage - Guide [:db_insert_placeholder_2] => Description value ) in drupal_write_record() (line 6975 of /Applications/MAMP/htdocs/includes/common.inc).Comment #10
saltednutHaving trouble recreating this error doing a manual test. Strange that the code is looking to do an insert in this case since it should be doing an update. Definitely would be good to start writing some more tests for the Bean UI.
Comment #11
indytechcook commentedI'm also unable to reproduce this.
@beanluc, can you try on a clean environment?
Comment #12
beanluc commentedStep 1: Clean Drupal installation, Standard install profile. Enable Bean rc3 and Bean Admin UI rc3.
Step 2: Try to create a Block Type. Leave Description empty. Result: white screen, error log captures
PHP Fatal error: Cannot instantiate abstract class BeanPlugin in sites/all/modules/bean/bean.module on line 347Step 3: Try to create a Block Type. Fill Description in. Result: white screen, error log captures
PHP Fatal error: Cannot instantiate abstract class BeanPlugin in sites/all/modules/bean/bean.module on line 347Now I can't even get as far as testing the condition where existing Bean-type needs to be edited and saved.
Comment #13
barraponto@beanluc you're using sqlite, right?
Comment #14
barrapontoI thought I had posted this before, but I'll post it now, since i've been affected by the same (or a similar) bug. Running
drush qd -y beantestsite beanwill setup a Drupal installation with bean and its dependencies enabled. It will use sqlite as database by default. Once it's up and running, enable bean_admin_ui (drush or admin/modules). Then, visit admin/structure/block-types and create a block type. It will take you back to admin/structure/block-types and nothing will be shown. Yet if you create another block type, the first one will show up, but not the new one.I'm uploading a video.
Comment #15
barrapontoHere's the video http://www.youtube.com/watch?v=aSRW9Xfphio
And I confirm it happens on mysql as well.
Yet it doesn't happen at all if the description is filled.
Comment #16
beanluc commentedNo, MySQL.
Comment #17
barrapontoMore info: it happens for the first block type I create, even if I set the description.
Comment #18
barrapontoI'm running PHP 5.3.6-13ubuntu3.6 with Suhosin-Patch on Ubuntu 11.10. I've tested with sqlite 2.8.17 and mysql 14.14 Distrib 5.1.61. I'm running lighttpd, but I don't think the web server is responsible for this.
Comment #19
barrapontotagging as Release blocker.
Comment #20
indytechcook commentedThanks @barraponto the video was perfect.
I was able to reproduce this in RC3. I just released RC4 which no longer has the issue. http://drupal.org/node/1538818
Comment #21.0
(not verified) commentedlinking to other issue
Comment #21.1
beanluc commentedredact
Comment #22
beanluc commentedThis is still present in rc-5, precisely as described in the original report above.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'academic_dept_whats_happening' for key 'name': INSERT INTO {bean_type} (name, label, description) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => academic_dept_whats_happening [:db_insert_placeholder_1] => Academic department What's Happening features [:db_insert_placeholder_2] => List three department announcements or content features in the upper right area of department page layouts. ) in drupal_write_record() (line 7013 of /Applications/MAMP/htdocs/**********/includes/common.inc).Exact same condition: Trying to edit a Bean type to include a description (was previously empty)
Comment #23
alexweber commentedI can confirm I couldn't replicate this in a fresh sandbox running RC5.
@beanluc are you testing on a fresh sandbox each time?
Comment #24
steinmb commentedI'll tested this module for a few days without seeing this and as mentioned in #20, it should have been fixed. @beanluc, do you have time to test it one more time?
Comment #25
beanluc commentedPristine Drupal sites don't have the problem. I can consider this fixed on that basis.
Unfortunately for me, at least one existing site implementation of mine hasn't benefited from the application of the 4 RC updates since I first reported it under rc-1.
Oh well!
Comment #26
steinmb commentedOK, what db server is this site running on? And could you do a 'DESCRIBE bean_type' or the equivalent for your db server type and post it? Perhaps the hook_update() that fixed it failed?
Comment #27
steinmb commentedComment #28
indytechcook commentedIt looks like comment #25 beanluc says it works fine on new sites, It's the sites with older versions that do not.
Comment #29
mhoff commentedI get a blank white screen when attempting to edit a bean type. This did not occur when bean was initially installed and it was used successfully for a few weeks. Several modules were installed since. Here is some information on our server.
Drupal 7.16
Bean 7.x-1.0-rc6
PHP Version 5.3.3
Apache 2.0 Handler
mysql 5.1.52
Comment #30
barrapontosorry @mhoff, but that doesn't seem to be a Bean issue. Please reopen if you figure out steps to reproduce the bug. Also, if you find it is a compatibilty issue with another module, open a new issue.
Comment #31.0
(not verified) commentedredact
Comment #32
enricotersi commentedI've find how to fix this issue.
I think the problem was due to the multilingual system.
bean_admin_ui.admin.inc file row 85
before
elseif (!method_exists($bean_type, 'getExportStatus') || $bean_type->getExportStatus() == 'Normal') {after
elseif (!method_exists($bean_type, 'getExportStatus') || $bean_type->getExportStatus() == t('Normal')) {Can you confirm?
Comment #33
damienmckennaHere's a patch for enricotersi's suggestion. Reading through the code it looks correct.
Lets add some tests to confirm it works correctly.
Comment #35
sgdev commentedI've found another way to trigger the integrity constraint violation. If a bean type has been exported to a feature, and modifications are later made to the bean structure, the export status will change to "Overridden". However, the conditional logic only triggers
$form['new']['#value'] = FALSEif the bean type does not have an export status, or has an export status oft('Normal').The error is generated by going to
/admin/structure/block-types/manage/<bean>/editand clicking "Save Block type" when a block type is in Overridden status. The code attempts to insert a new bean type because$form_state['values']['new']is set toTRUE, when it should beFALSE.This can be fixed by either including Overridden, or disabling the Save button when in the Overridden state. I think including Overridden is better, since it allows a site builder to modify a bean name or description when Overridden. However we need to ensure
machine_nameis not modified, otherwise it will break the exported feature.See the updated patch. I'd appreciate your feedback.
Comment #37
sgdev commentedJust found a bug in patch #35 when creating a new bean type. I'll post an update shortly.
Comment #38
sgdev commentedOk, this new patch seems to be working as I would expect. When creating a bean type, an error was generated due to the
$bean_type->getExportStatus() == t('Overridden')code.The
export_statusindex doesn't exist until the bean type has been saved, so I added a check togetExportStatusto determine if it is set. I also modified the conditional to use anin_arrayinstead of multipleORs.Comment #40
sgdev commentedI've looked at the code a little more closely to see if there was a way I could avoid modifying
getExportStatus. I was able to do so, but there are a couple of things about the existing code that make no sense.FIrst, if visiting the admin form for an existing bean type, the "Delete Block type" button is unset if
export_statusis Normal. Why? I can go toadmin/structure/block-typesand click the "Delete" link to delete the bean type. Does not make sense why the link is available on the summary page, but not the edit page.Second, the
submitfunction sets a value for$form_state['redirect']if the operation isrevertordelete, but then six lines later,$form_state['redirect']is changed. Why is$form_state['redirect']set to a value, and then immediately modified? I can't see a reason why it would be.I've made some changes to the previous patch that should resolve these issues.