Following on from legitimate issues reported in: #1599396: Fatal Error: Call to a member function internalIdentifier() on a non-object and #1621686: Call to a member function internalIdentifier() on a non-object in registration/includes/registration.forms.inc line 90

Resolve when properties of Registration entities when they are of an unacceptable value.

Eg: author of registration no longer exist will cause Registration->author->uid to result in not an object/not set error.

Affected properties:

  • Registration->author
  • Registration->entity
  • Registration->state
  • Registration->user

Code should not use isset($registration->author). When $registration->author is unavailable, it will be FALSE. isset(FALSE) results in true. Instead, simply checking for boolean true is enough.

Please see patch.

Issues not covered in patch

Autoloading entities

Consider modifying Registration::__construct so it does not autoload entities. Not all entities should autoload its related entities, why should Registration do the same.

Remove Registration->author/entity/state/user properties.

Make user/entity/state/user methods public. Each of these methods have their related entities statically cached by Drupal. So there is no performance loss.

Entity metadata wrappers

Implement hook_entity_property_info so existing registration entity properties still operate normally.

See also:

Comments

dpi’s picture

Fix incorrect diff, add test.

dpi’s picture

Issue summary: View changes

formatting

dpi’s picture

Issue summary: View changes

wrapper

levelos’s picture

Status: Needs review » Fixed

Thanks @dpi, committed. Re: your other suggestion, I realize we don't have to, but not sure why we shouldn't. Feel free to open a new ticket to discuss.

Status: Fixed » Closed (fixed)

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

blainelang’s picture

Status: Closed (fixed) » Active

Sorry to re-open this but using the latest DEV snapshot and beta3 of commerce_registration, I am seeing Call to a member function internalIdentifier() on a non-object - line 92 in registration.forms.inc.

The method internalIdentifier is not known for the registration->state property.

It was working just fine and then while working on adding a rule to handle disabling the registration pane, this issue started to appear as soon as the checkout page was shown. Disabling that rule and now it still occurs so that was likely unrelated but the complete checkout was working at one point.

The registration states were initially default and then after getting this error, I've tried enabling the 'show on form' and active for additional states but no change. Can't clear the error and be able to checkout.

levelos’s picture

Status: Active » Closed (fixed)

Perhaps you're using the wrong version of Entity. Re: different issue, please don't hijack, this one is resolved.

levelos’s picture

Issue summary: View changes

fix link

  • levelos committed bef1bce on 7.x-1.x, panels, any-entity, slots, integrations, hold_state authored by dpi
    #1627210 by dpi: Handling when a host entity is unavailable.