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".

Files: 
CommentFileSizeAuthor
#5 entity-entity_ui_get_page_title-1777110-4.patch773 bytessachin_hj
#3 entity-entity_ui_get_page_title-1777110-3.patch1.83 KBlevelos
PASSED: [[SimpleTest]]: [MySQL] 409 pass(es).
[ View ]
#1 entity_ui_get_page_title_needs_to_check_if_entity_is_null.1777110-1.patch1.46 KBdroath
PASSED: [[SimpleTest]]: [MySQL] 374 pass(es).
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new1.46 KB
PASSED: [[SimpleTest]]: [MySQL] 374 pass(es).
[ View ]

I think that I'm encountering this issue as well. I've got a hook_entity_info() implementation with the following in it.

    'admin ui' => array(
      'path' => 'admin/memberships',
      'file' => 'membership_entity.pages.inc',
      'controller class' => 'EntityDefaultUIController',
      'menu wildcard' => '%membership_entity',
    ),

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.

StatusFileSize
new1.83 KB
PASSED: [[SimpleTest]]: [MySQL] 409 pass(es).
[ View ]

Updated patch against head.

Status:Needs review» Needs work

The last line of code needs to be inside the test as it uses $bundle, which is set by list() inside the test.

<?php
  
if (isset($entity)) {
       ...
     list(, ,
$bundle) = entity_extract_ids($entity_type, $entity);
   }
   return
entity_ui_get_action_title($op, $entity_type, $bundle);
?>

We then need to decide what to return if the test fails.

Issue summary:View changes
StatusFileSize
new773 bytes

Hey 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).]