If you do a search (view) and some entities in the index are not available any more, you get a bunch of notices (see below). As that probably can happen sometimes, this case should probably be handled better.

# Notice: Trying to get property of non-object in entity_extract_ids() (line 7065 of /...../includes/common.inc).
# Notice: Trying to get property of non-object in node_uri() (line 250 of /...../modules/node/node.module).
# Notice: Undefined index: title in SearchApiViewsHandlerField->render() (line 131 of /...../profiles/recruiter/modules/search_api/contrib/search_api_views/includes/handler_field.inc).
# Notice: Undefined index: search_api_views_entity in SearchApiViewsHandlerField->renderLink() (line 176 of /...../profiles/recruiter/modules/search_api/contrib/search_api_views/includes/handler_field.inc).
# Notice: Trying to get property of non-object in entity_extract_ids() (line 7065 of /...../includes/common.inc).
# Notice: Trying to get property of non-object in node_uri() (line 250 of /...../modules/node/node.module).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Title: lots of notices if entities are missing » Lots of notices if entities are missing
Status: Active » Needs review
FileSize
1004 bytes

Hm, normally, hook_entity_delete() should take care that the entity isn't returned anymore, so I don't really know when a result wouldn't be available.
However, I tried it with a little more checks. Does this help?

fago’s picture

yep, however I guess it would be better to don't add the row to views at all + reduce the result count?

Indeed hook_entity_delete() should take care of those - I experienced it by using it wrong: query the solr server of another site... But I guess I can happen in practice too, consider someone searching after an entity is deleted, but the hook is not yet called.

drunken monkey’s picture

FileSize
642 bytes

OK, the time between deletion and hook invocation should be around one millisecond, so I don't think this is very likely. But sure, we should get this, and you're absolutely right that just not displaying the row is way better. I just thought, this would be harder to do, but in the end I just had to delete one line. Patchj attached. ;)

drunken monkey’s picture

Status: Needs review » Fixed

Committed.

fago’s picture

Status: Fixed » Active

That works fine for me, however the pager is not yet updated. I guess we would have to fix $this->pager->total_items too.

drunken monkey’s picture

How would you propose to fix this? Or, what would you say is wrong with the pager currently?
As I see it, there is no way to tell how many "loadable" results there really are, and just subtracting the unloadable items of the current page from the total count would possibly make the last page invisible, along with the results there. I think the field is correct as it is.

Also, we're dealing with a complete edge case here. I think, just avoiding to show warnings or the like is all we need to do.

fago’s picture

Status: Active » Fixed

>Also, we're dealing with a complete edge case here.
Agreed, so let's just leave it like that. I was not sure about it either.

Status: Fixed » Closed (fixed)

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