Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We need to check if the entity is set within the entity_ui_get_page_title function. So we don't result in getting a PHP fatal error "Call to a member function label() on a non-object".
Comments
Comment #1
droath CreditAttribution: droath commentedComment #2
eojthebraveI think that I'm encountering this issue as well. I've got a hook_entity_info() implementation with the following in it.
And this works fine in terms of regular expected usage and managing entities. However if you navigate to a page like 'admin/membership/asdf/fdsa' which isn't a valid menu path it gets the closest match which is 'admin/memberships', and then ends up calling
entity_ui_get_page_title()
with $entity = 'asdf' which results in a fatal error.I think a check like what is in the above test is in the right direction but should probably do an is_object($entity) check instead of an isset($entity) since $entity could be just set to whatever string is in the path.
Comment #3
levelos CreditAttribution: levelos commentedUpdated patch against head.
Comment #4
zeta ζ CreditAttribution: zeta ζ commentedThe last line of code needs to be inside the test as it uses $bundle, which is set by list() inside the test.
We then need to decide what to return if the test fails.
Comment #5
sachin_hj CreditAttribution: sachin_hj commentedHey your patch works fine but there is a mismatch in the line number so i have updated it.
[For Your Reference Error Message what i got was
Notice: Undefined variable: bundle in entity_ui_get_page_title() (line 749 of /Project Name/sites/all/modules/contrib/entity/includes/entity.ui.inc).]
Comment #6
pachabhaiya CreditAttribution: pachabhaiya commentedPatch #3 looks good to me.
It applied successfully in my entity-7.x-1.3 version and solved the issue as mentioned in the issue description.
Patch #3 does not apply cleanly in the latest 7.x-1.x-dev version.
I'm re-rolling this patch and submitting it here so that it applies cleanly in the latest 7.x-1.x-dev version.
@zeta ζ
The line of code that you have mentioned does not necessarily have to be inside the 'if (isset($entity))' condition.
The value of $bundle will be NULL is the condition does not satisfy.
Changing status to Needs review.
Comment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 3 year old re-rolled patch in #6 does not apply to the latest entity 7.x-1.x-dev and (if still relevant) needs a reroll, again ;(