db_like depricated in Drupal 9

Created on 23 April 2021, over 3 years ago
Updated 25 April 2023, over 1 year ago

Problem/Motivation

Error: Call to undefined function Drupal\alter_entity_autocomplete\AlterEntityAutocomplete\db_like() in Drupal\alter_entity_autocomplete\AlterEntityAutocomplete\AlterEntityAutocompleteMatcher->getMatches() (line 46 of ../public_html/modules/contrib/alter_entity_autocomplete/src/AlterEntityAutocomplete/AlterEntityAutocompleteMatcher.php)

db_like() deprecated in Drupal 9

Proposed resolution

Add
use Drupal\Core\Database\Database

in alter_entity_autocomplete/src/AlterEntityAutocomplete/AlterEntityAutocompleteMatcher.php
change line 46
from
$query->condition($target_entity_field, '%' . db_like($string) . '%', 'like');
to
$query->condition($target_entity_field, '%' . Database::getConnection()->escapeLike($string)) . '%', 'LIKE');

Remaining tasks

create patch

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇵🇭Philippines ppblaauw

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024