Problem/Motivation

Watchdog is full of messages reporting:

"Could not load the following items on index Search_index: "entity:product/3105444:it", "entity:product/2056973:it", "entity:product/2114185:it". "

Steps to reproduce

In the index config I have disabled the indexing of a specific language for the content type product because we use another search engine there, but the translation exists.

When saving an italian translation of an entity, we see the above error message.

Proposed resolution

We check validity of content when inserting but not when updating/deleting an entity. I propose we ought to do the same.

Basically in ContentEntityTrackingManager.php::trackEntityChange we should change the following:

    foreach ($indexes as $index) {
      if ($inserted_ids) {
        $filtered_item_ids = $this->filterValidItemIds($index, $datasource_id, $inserted_ids);
        $index->trackItemsInserted($datasource_id, $filtered_item_ids);
      }
      if ($updated_ids) {
        $index->trackItemsUpdated($datasource_id, $updated_ids);
      }
      if ($deleted_ids) {
        $index->trackItemsDeleted($datasource_id, $deleted_ids);
      }
    }

to:


    foreach ($indexes as $index) {
      if ($inserted_ids) {
        $filtered_item_ids = $this->filterValidItemIds($index, $datasource_id, $inserted_ids);
        $index->trackItemsInserted($datasource_id, $filtered_item_ids);
      }
      if ($updated_ids) {
        $filtered_item_ids = $this->filterValidItemIds($index, $datasource_id, $updated_ids);
        $index->trackItemsUpdated($datasource_id, $filtered_item_ids);
      }
      if ($deleted_ids) {
        $filtered_item_ids = $this->filterValidItemIds($index, $datasource_id, $deleted_ids);
        $index->trackItemsDeleted($datasource_id, $filtered_item_ids);
      }
    }

Is there something I've done wrong somewhere which means this isn't necessary? The entity translation exists in my DB but the index item does not and seems correct to me. I have already tried deleting the entire index and rebuilding

Comments

willeaton created an issue. See original summary.

drunken monkey’s picture

Component: General code » Plugins
Status: Active » Needs review
StatusFileSize
new4.21 KB
new6.46 KB

Thanks a lot for reporting this problem, and sorry it took me a while to respond.
I could indeed easily reproduce this bug, seems like a small oversight. The attached should fix it. Please test/review.

The last submitted patch, 2: 3246615-2--error_on_update_of_ignored_translation--tests_only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

drunken monkey’s picture

Would you mind giving this a try so I can commit it? Thanks!

(Attaching revision just fixing the code style problem.)

  • drunken monkey committed ec46bdc on 8.x-1.x
    Issue #3246615 by drunken monkey: Fixed error when saving an unindexed...
drunken monkey’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

miiimooo’s picture

I'm not the original reporter of this issue but I can confirm it fixed this issue for me too.