Duplication for Empty Fields

Created on 25 October 2024, 21 days ago

Problem/Motivation

We have multiple search attachment fields in our index and I've noticed that if certain fields have files while others do not, the empty fields get filled with the previous file content. This causes our index to contain duplicate data on fields that should not contain that information and negatively effects the relevance scoring.

Duplicate fields:

Expected result

Proposed resolution

If looks like $files will persist during different field iterations. So if the value is set, and on another iteration an empty field causes the statement to break out of the checks, it falls back to if (!empty($files) where it uses the previous file.

A simple solution is just to add a check for $all_fids such as: if (!empty($files) && !empty($all_fids)) {

A better fix may be to pull the loading of files outside the conditional check so that it's always updated.

$files = $this->entityTypeManager
              ->getStorage('file')
              ->loadMultiple($fids);

πŸ› Bug report
Status

Active

Version

9.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States j-barnes

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024