When using the admin UI (with entity that has bundles) and accessing the menu-path of the entity adding form, the function entity_ui_get_page_title() calls core function entity_extract_ids() with entity object which does not have bundle-property set, which results to EntityMalformedException "'Missing bundle property on entity of type".

Entity API 1.1->1.2 update added following lines (746-748) to entity.ui.inc:

if (isset($entity)) {
  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
}

In this case the $entity here is from EntityAPIController::create(), only with one property named "is_new", but entity_extract_ids() mandates the $entity should have it's bundle property set as defined in entity-info.

Should there be a check that $entity is "not new", also, before calling entity_extract_ids()?

CommentFileSizeAuthor
#1 2074215-get-page-title-1.patch518 bytesbucefal91
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bucefal91’s picture

Status: Active » Needs review
FileSize
518 bytes

Hello!

I observe the same bug in 7.2 version of entity API module. Your suggestion seems correct to me and I made a patch based on it. Please, review.

Thank you!

Status: Needs review » Needs work

The last submitted patch, 2074215-get-page-title-1.patch, failed testing.

bucefal91’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Needs work » Needs review

Crap... the provided patch should be applied against 7.x-1.x-dev. I am going to change the version in this issue.

bucefal91’s picture

#1: 2074215-get-page-title-1.patch queued for re-testing.

thirdender’s picture

This definitely fixes an issue caused by Entity API 7.x-1.2 and the Units of Measurement module. Is it possible to get this committed to the -dev branch?

jordan8037310’s picture

Thanks for the fix, bucefal91!

manuelBS’s picture

The patch also works for me, thanks!

bethsoderberg’s picture

The patch worked for me as well. Thanks bucefal91!

PlayfulWolf’s picture

Issue summary: View changes

Is this patch safe to apply to 1.3 version?

EDIT: Latest dev maybe?...

PlayfulWolf’s picture

Status: Needs review » Reviewed & tested by the community

Patch works for me too. Applied to 1.3 version manually.

fago’s picture

Status: Reviewed & tested by the community » Needs work

Should there be a check that $entity is "not new", also, before calling entity_extract_ids()?

Nope, even new entities must have a bundle. So the problem is the code which creates the entity object without bundle.

SocialNicheGuru’s picture

is this still an issue in entity 1.5?

PlayfulWolf’s picture

Yes. Just upgraded and tested.

klokie’s picture

patch worked for me against entity 1.5. Thanks!

stefika’s picture

Just to say, patch is worked for entity 1.4. Updated manually. Thank you!

asb’s picture

Status: Needs work » Reviewed & tested by the community

Patch still applies (almost) cleanly against entity 1.5:

$ patch -p1 < 2074215-get-page-title-1.patch 
patching file entity.module
Hunk #1 succeeded at 200 with fuzz 1.

We have at least half a dozend reports that the patch is working and fixes an issue, changing status to get it into dev.

fago’s picture

Status: Reviewed & tested by the community » Needs work

Still, it's wrong and not the right fix - see #11.

bucefal91’s picture

Hello!

For those who came here because of Units module: it turned out that Units module contained a bug, which I just fixed. The bug is fixed in 7.x-1.0-beta1 release of Units module. It was released a few minutes ago.

fago, sorry for blaming Entity API module. To your credit, you never accepted the bug was in Entity API module :)

I am not closing this issue, because I think there are folks who participated in here not because of Units module.