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:
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | registration-host-entity-not-available-2.patch | 9.95 KB | dpi |
| registration-host-entity-not-available.patch | 10.99 KB | dpi |
Comments
Comment #1
dpiFix incorrect diff, add test.
Comment #1.0
dpiformatting
Comment #1.1
dpiwrapper
Comment #2
levelos commentedThanks @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.
Comment #4
blainelang commentedSorry 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.
Comment #5
levelos commentedPerhaps you're using the wrong version of Entity. Re: different issue, please don't hijack, this one is resolved.
Comment #5.0
levelos commentedfix link