I've now installed Bean twice and this is definitely a reproducable issue for me and it means I can't actually use Beans yet although I really want to give it a go!

Installed 7.x-1.1 on Drupal 7.21
I'm using Entity API 7.x-1.0-rc3

Steps to reproduce:

  1. Install Bean via drush dl
  2. Activate Bean and Bean Admin UI modules
  3. Create a new Bean type - called 'Blat'
  4. Add a single text field to that bean type. The first time I tried it I created a text area called body (machine name field_body) which I suspect may be the issue here.
  5. Save the bean type
  6. Create new bean of type Blat
  7. Fill in junk in all the fields and hit save.
  8. This is where it starts to look odd. The first bean block I try to create returns a page with the message:
    Blat l;jkhlkj has been created.
    Page not found The requested page "/block/ljkhlkj/view" could not be found.
  9. Then the next bean block I try and save results in a PDO Exception error:
    PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'vid': INSERT INTO {bean} (vid, delta, label, title, type, view_mode, data, uid, created, changed) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => ljkhlkjkhjgjkhg [:db_insert_placeholder_2] => l;jkhlkjkhjgjkhg [:db_insert_placeholder_3] => l;kjl;kjjkhghjkg [:db_insert_placeholder_4] => blat [:db_insert_placeholder_5] => default [:db_insert_placeholder_6] => a:1:{s:9:"view_mode";s:7:"default";} [:db_insert_placeholder_7] => 1 [:db_insert_placeholder_8] => 1363237916 [:db_insert_placeholder_9] => 1363237916 ) in drupal_write_record() (line 7106 of /[mysite]/includes/common.inc).
    

Any ideas what I've broken or what I'm missing?

To try and get it working I disabled all the bean modules, uninstalled all the bean modules and tried the whole process again but still no luck.

CommentFileSizeAuthor
#9 specify-entity-1942558-9.patch409 bytesdavidwbarratt

Comments

saltednut’s picture

Can you reproduce this error using the latest dev?

marblegravy’s picture

Just tried again with a fresh install and the dev version and the steps to reproduce above still apply and I can't create bean blocks. The first one results in a page not found, the second results in the PDO error.

This time I didn't use a common field (I used field_body the first time in #1) name and just created an image field. So that's not where the issue was coming from.

The PDO error at the end is exactly the same as the one above.

Does it make a difference that I'm using an installation profile? I might try it out with a vanilla Drupal install and see if I still get the same issue.

saltednut’s picture

Status: Active » Postponed (maintainer needs more info)

It COULD make a difference. Does the install profile patch core?

marblegravy’s picture

The profile doesn't touch core. It's just the way we deploy our stuff.

OK, So I've tried again with a fresh everything (still in our profile) and I've got the following notes:

When Bean is installed it creates the bean, bean_revision and bean_type tables in the db.

I create a bean type and it appears in the db ok.

The first time I create a bean, a db entry is created in the bean table (to confuse things, I called the bean 'Title' but I did not create any other fields):

bid	vid	delta	label	title	type	view_mode	data	uid	created	changed
1	0	title	Title	This is the title	content	default	a:1:{s:9:"view_mode";s:7:"default";}	1	1363742171	1363742171

The bean_revision table is still empty.

however, the result page still could not be found: The requested page "/block/title/view" could not be found.

Going back to the block content page at /admin/content/blocks, it claims there are no blocks.

Trying to create a new block for a second time, we get the PDO exception:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'vid': INSERT INTO {bean} (vid, delta, label, title, type, view_mode, data, uid, created, changed) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => second [:db_insert_placeholder_2] => Second [:db_insert_placeholder_3] => Second block [:db_insert_placeholder_4] => content [:db_insert_placeholder_5] => default [:db_insert_placeholder_6] => a:1:{s:9:"view_mode";s:7:"default";} [:db_insert_placeholder_7] => 1 [:db_insert_placeholder_8] => 1363743238 [:db_insert_placeholder_9] => 1363743238 ) in drupal_write_record() (line 7106 of [mysite]/includes/common.inc).

Checking the db, there's still the initial row in the bean table, but obviously no sign of the second one that resulted in the PDO exception.

If I delete the row in the bean table, I can reproduce the process above every time.

So it seems that for some reason, my site isn't reading the beans table correctly. But I've got no idea where to look for the problem. Any ideas?

marblegravy’s picture

Success!
I just started from scratch again but installed the dev builds of both bean and entity API. So I am currently running bean 7.x-1.1+10-dev and Entity API 7.x-1.0+2-dev and it works!

Looking at the bean table now I can see both the first and second bean I created, with the only real difference being that the value in vid is now non-zero for bid 1:

bid	vid	delta	label	title	type	view_mode	data	uid	created	changed
1	1	first-bean	First bean	This is the first bean	demo	default	a:1:{s:9:"view_mode";s:7:"default";}	1	1363744836	1363744836
3	3	second-bean	Second bean	Second bean	demo	default	a:1:{s:9:"view_mode";s:7:"default";}	1	1363744882	1363744882

So not knowing a great deal about the inner workings of Bean or the Entity API, I suspect that might be a clue?

Interestingly, I continued to add a bunch more beans and each time the bid and vid values incremented by two.

Final thing to note is that the bean_revision table is also now being populated when new beans are created where previously they were not.

So my immediate issue is now fixed, so unless you think this needs further investigation I'm happy to mark is as resolved.

saltednut’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I'm going to close this since we can't reproduce it.

I would suggest filing a new issue regarding:

Interestingly, I continued to add a bunch more beans and each time the bid and vid values incremented by two.

That seems like a separate issue.

john bickar’s picture

I realize this issue is closed, but the problem here is that you need a newer version of entity than 1.0-rc3 (one that supports revisions). I'm not sure exactly when that went in, but it was in there by 1.0 (and current version is 1.1)

davidwbarratt’s picture

Status: Closed (cannot reproduce) » Active

I'm experiencing this problem as well, perhaps Bean should specify the version of Entity API that is required in the .info file?
https://www.drupal.org/node/542202#dependencies

Thanks!

davidwbarratt’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Category: Support request » Task
Status: Active » Needs review
StatusFileSize
new409 bytes

The attached patch will stop the user from enabling Bean until they have a version of Entity API that is high enough to use. In my testing, 7.x-1.0 was the minimum version that can be used to avoid this problem.

indytechcook’s picture

Status: Needs review » Fixed

Thanks, pushed to 7.x-1.x

Status: Fixed » Closed (fixed)

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