Entity lookup returns FALSE in case of no results

Created on 8 August 2023, 11 months ago

Problem/Motivation

Entity lookup returns FALSE in case of no results. This causes issues when this FALSE value is assigned to a taxonomy entity reference field on a node type:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'tid' at row 1: INSERT INTO "taxonomy_index" ("nid", "tid", "status", "sticky", "created") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 50399 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 1681821753 ) in taxonomy_build_node_index() (regel 345 van /Users/dieterholvoet/Projects/sites-minsky/easy-life/web/core/modules/taxonomy/taxonomy.module).

False is assigned to the target_id property, which causes FALSE to be inserted as the tid column in taxonomy_build_node_index, which causes the error above.

Proposed resolution

Return NULL instead of FALSE.

πŸ› Bug report
Status

Needs review

Version

6.0

Component

Plugins

Created by

πŸ‡§πŸ‡ͺBelgium DieterHolvoet Brussels

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

Comments & Activities

Production build 0.69.0 2024