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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

beanluc’s picture

Issue summary: View changes

Describing conditions

indytechcook’s picture

Status: Active » Postponed (maintainer needs more info)

Is this still an issue since that code has been commttted?

beanluc’s picture

Version: 7.x-1.0-rc1 » 7.x-1.0-rc2

Who 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 16

beanluc’s picture

This fixes the whitescreen. Now I'll check the actual issue here.

beanluc’s picture

No, 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.

beanluc’s picture

Status: Postponed (maintainer needs more info) » Needs review
beanluc’s picture

OK, 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.

Status: Needs review » Needs work

The last submitted patch, bean-whitescreen-1452312-2.patch, failed testing.

indytechcook’s picture

Sorry 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

beanluc’s picture

rc3 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).

saltednut’s picture

Having 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.

indytechcook’s picture

Version: 7.x-1.0-rc2 » 7.x-1.0-rc3
Status: Needs work » Active

I'm also unable to reproduce this.

@beanluc, can you try on a clean environment?

beanluc’s picture

Step 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 347

Step 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 347

Now I can't even get as far as testing the condition where existing Bean-type needs to be edited and saved.

barraponto’s picture

@beanluc you're using sqlite, right?

barraponto’s picture

I 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 bean will 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.

barraponto’s picture

Here'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.

beanluc’s picture

you're using sqlite, right?

No, MySQL.

barraponto’s picture

More info: it happens for the first block type I create, even if I set the description.

barraponto’s picture

I'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.

barraponto’s picture

Issue tags: +Release blocker

tagging as Release blocker.

indytechcook’s picture

Status: Active » Fixed

Thanks @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

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

linking to other issue

beanluc’s picture

Issue summary: View changes

redact

beanluc’s picture

Version: 7.x-1.0-rc3 » 7.x-1.0-rc5
Status: Closed (fixed) » Active

This 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)

alexweber’s picture

I can confirm I couldn't replicate this in a fresh sandbox running RC5.

@beanluc are you testing on a fresh sandbox each time?

steinmb’s picture

Status: Active » Postponed

I'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?

beanluc’s picture

Pristine 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!

steinmb’s picture

OK, 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?

steinmb’s picture

Version: 7.x-1.0-rc5 » 7.x-1.x-dev
Status: Postponed » Postponed (maintainer needs more info)
indytechcook’s picture

Status: Postponed (maintainer needs more info) » Fixed

It looks like comment #25 beanluc says it works fine on new sites, It's the sites with older versions that do not.

mhoff’s picture

Status: Fixed » Needs work

I 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

barraponto’s picture

Status: Needs work » Fixed

sorry @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.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

redact

enricotersi’s picture

Issue summary: View changes

I'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?

DamienMcKenna’s picture

Status: Closed (fixed) » Needs review
Issue tags: -Release blocker +Needs tests
FileSize
650 bytes

Here's a patch for enricotersi's suggestion. Reading through the code it looks correct.

Lets add some tests to confirm it works correctly.

Status: Needs review » Needs work

The last submitted patch, 33: bean-n1452312-33.patch, failed testing.

ron_s’s picture

Status: Needs work » Needs review
FileSize
1.45 KB

I'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'] = FALSE if the bean type does not have an export status, or has an export status of t('Normal').

The error is generated by going to /admin/structure/block-types/manage/<bean>/edit and 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 to TRUE, when it should be FALSE.

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_name is not modified, otherwise it will break the exported feature.

See the updated patch. I'd appreciate your feedback.

Status: Needs review » Needs work

The last submitted patch, 35: bean-n1452312-35.patch, failed testing.

ron_s’s picture

Just found a bug in patch #35 when creating a new bean type. I'll post an update shortly.

ron_s’s picture

Status: Needs work » Needs review
FileSize
1.99 KB

Ok, 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_status index doesn't exist until the bean type has been saved, so I added a check to getExportStatus to determine if it is set. I also modified the conditional to use an in_array instead of multiple ORs.

Status: Needs review » Needs work

The last submitted patch, 38: bean-n1452312-38.patch, failed testing.

ron_s’s picture

Status: Needs work » Needs review
FileSize
3.79 KB

I'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_status is Normal. Why? I can go to admin/structure/block-types and 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 submit function sets a value for $form_state['redirect'] if the operation is revert or delete, 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.

Status: Needs review » Needs work

The last submitted patch, 40: bean-n1452312-40.patch, failed testing.