$index->item_type is not the same as $index->getEntityType() and is not guaranteed to be the Entity type (it differs for search api entity translation for example). Here is a patch to fix this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gnucifer created an issue. See original summary.

gnucifer’s picture

Title: $index->item_type when should be using $index->getEntityType() » $index->item_type when should be $index->getEntityType()
gnucifer’s picture

drunken monkey’s picture

Thanks for spotting this. The whole function is a mess, it seems to me, but since I have no idea what's going on there, I unfortunately have no way of fixing it.

Your patch looks quite sensible, though – however, since getEntityType() can return NULL, this code would result in chaos for non-entity indexes. I think my revised patch should work better, and also fix another stupid mistake in that function (or it's on purpose and I just don't understand it – please test/review and be the judge of that!).

In any case, thanks a lot again for posting this!

drunken monkey’s picture

Could you please give my patch a short try to determine whether it solves your problem? Then I can commit it.

gnucifer’s picture

Thanks for your comments. Sorry about the late reply. Good catch, to me it looks like the whole block can be removed:

  if (isset($conf['page'])) {
    $info = search_api_page_load($page);
    $index = search_api_index_load($info->index_id);
  }

since neither $info nor $index is referenced below. I don't have to possibility to upload a new patch right now, but as far as I can see that block should go.

drunken monkey’s picture

$index is referenced below (in the second change of the patch, in fact), so I don't think it can go.
What can go is the key in the foreach loop, though.
Otherwise, does the patch work for you?

gnucifer’s picture

Oh, I must have missed that. Yes the patch looks good to me!

  • drunken monkey committed afc97c4 on 7.x-1.x
    Issue #2711499 by drunken monkey, gnucifer: Fixed page manager...
drunken monkey’s picture

Status: Needs review » Fixed

OK, good to hear. Thanks for reviewing!
Committed.

Status: Fixed » Closed (fixed)

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