I'm getting the "Fatal error: Call to a member function label() on a non-object in /sites/all/modules/contrib/entity/entity.module on line 1075" error when I click on "Import mailchimp activity entity" (on /admin/config/services/mailchimp/activity/import) using the MailChimp module. Updating the module to 7.x-1.2 does not fix the issue :-(

Anyone having this issue?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SchnWalter’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.68 KB

It looks like EntityDefaultUIController::hook_menu() calls drupal_get_form with NULL instaed of an entity. entity_ui_get_page_title() crashes when trying to get the label. There is a fix in the attached diff.

Status: Needs review » Needs work

The last submitted patch, 1: 2112755-fix_entity_ui_get_page_title.diff, failed testing.

SchnWalter’s picture

FileSize
1.59 KB

Added patch

SchnWalter’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
SchnWalter’s picture

Status: Needs work » Needs review
ruscoe’s picture

Refactored entity_ui_get_page_title to avoid function call on non-object in entity_label when $entity is NULL. Patched against latest dev version.

magicmyth’s picture

Patch #6 works for me against 7.x-1.5 and solves the problem I was having with Mailchimp module. Holding of on RTBC this until I've tested a bit more but looking good so far.

entendu’s picture

#6 works for me and solves a problem with importing Workflows. Commit ASAP IMO.

magicmyth’s picture

Status: Needs review » Reviewed & tested by the community

Nothing has gone boom after over a week so RTBC.

basvredeling’s picture

Agreed, patch in #6 is fine

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
2.17 KB

Although this issue should be resolved asap, the patch in #6 is broken. By removing the check for an entity, you're just moving the WSOD further down the line, check entity_extract_ids():

  if (!empty($info['entity keys']['bundle'])) {
    // Explicitly fail for malformed entities missing the bundle property.
    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
    }
    $bundle = $entity->{$info['entity keys']['bundle']};
  }

Attached is a different approach.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #11 fixes this bug for me, as it occurs in the CER module: #2341403: WSOD at admin/config/content/cer/import. Marking RTBC.

basvredeling’s picture

#11 looks good

fago’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/entity.module
@@ -184,28 +184,30 @@ function entity_ui_entity_page_view($entity) {
   return entity_ui_get_action_title($op, $entity_type, $bundle);

This now calls entity_ui_get_action_title() with other than the support opersations, thus is bogus.

I'd suggest keeping the old flow instead but falling back to another label if no $entity is given, e.g. the entity type label.

kristiaanvandeneynde’s picture

Status: Needs work » Needs review

I'm not sure...

How does it call that entity_ui_get_action_title() with any $op except 'add' and 'import'? Any other operation requires an entity ('edit', 'clone', 'delete', 'revert', 'view', 'export') and would thus get caught in the switch.

The only ones that should fall through are the ones that generally don't need an entity at all: 'add', 'import' and any other unsupported operator that someone should manually pass on, which would break anyway.

fago’s picture

Status: Needs review » Needs work

Any other operation requires an entity ('edit', 'clone', 'delete', 'revert', 'view', 'export') and would thus get caught in the switch.

Not any more if the entity is NULL. The documentation says I can call it without entity in all cases, thus it should work in all of those cases. I'd suggest generating $label as the entity type label if no entity is passed and keeping the existing flow of things.

kristiaanvandeneynde’s picture

Okay, I'll try to update the patch when I can (currently at Drupalcon).

ofry’s picture

Status: Needs work » Needs review
FileSize
1.86 KB

There is my patch with generating $label as entity type label if $entity = NULL.

Status: Needs review » Needs work

The last submitted patch, 18: entity-fixed-call-non-object-label-2112755-17.patch, failed testing.

phenaproxima’s picture

Status: Needs work » Needs review
FileSize
1.66 KB

@ofry, it looks like that patch had bad header information (it contained the full path to your clone of Entity API, starting with "C:/"), so the testbot couldn't handle it. I have re-rolled the patch and attached it.

kristiaanvandeneynde’s picture

Status: Needs review » Needs work

The patch in #18 (copied in #20) contains several flaws:

  • You check for an entity and when there isn't one, try to extract the bundle
  • You copy code from entity_ui_get_action_title() instead of just calling that function
  • Whitespace at the end of a line (meh)
  • You added a new return value
phenaproxima’s picture

Status: Needs work » Needs review
FileSize
1.43 KB

Here's a streamlined and modified version of @ofry's patch, addressing the issues you mentioned. Even the whitespace. ;)

phenaproxima’s picture

FileSize
1.4 KB

Nah, screw that, here's a better one.

phenaproxima’s picture

Hiding broken patches in issue summary.

kristiaanvandeneynde’s picture

Isn't this much cleaner?

It takes a small hit on extracting the bundle whether you need it or not, but has all the checks at the top.

kristiaanvandeneynde’s picture

#23 looks clean too, so I'm even.

phenaproxima’s picture

I like your version better. #25 looks great to me.

kristiaanvandeneynde’s picture

Status: Needs review » Reviewed & tested by the community

Great, back to fago then :)

fago’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

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