Problem/motivation

The entity matcher compares the search string against the entity label only. For nodes that is the title, matched with LIKE:

$query->condition($label_key, '%' . $search_string . '%', 'LIKE');

An editor who knows a page's ID (for example copied from a report or from the URL) cannot find it by typing the bare ID: typing 42231 returns "No results", while /node/42231 does match. The ID is the one identifier that is guaranteed unique when several pages share a title.

Steps to reproduce

  1. Use a Linkit profile with the Content (node) matcher.
  2. In the link dialog, type the numeric ID of an existing, published node.
  3. No suggestion is returned; /node/<id> does return it.

Proposed resolution

When the search string is numeric, also match the entity ID, in addition to the existing label condition. Non-numeric input is unchanged, and config entities keep their current CONTAINS behaviour.

Remaining tasks

  • Review
  • Test coverage (an EntityMatcher test with a numeric search string)

Patch attached, against 7.x.

Issue fork linkit-3630280

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

u_tiwari created an issue. See original summary.

ishfaqafridi85’s picture

I will check the patch locally and add test coverage for searching by entity ID.

ishfaqafridi85’s picture

Status: Active » Needs review

Added MR !190 using @u_tiwari’s patch, with tests for numeric ID searches,
title matches and access restrictions. Locally, 22 tests with 236 assertions passed, and PHPCS passed.

AI disclosure: AI assisted with the test code, and i tested and verify manually.

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new90.23 KB
new55.9 KB
new48.97 KB

✅ Tested and works — applied MR !190 on 7.x, rebuilt caches, and searched for the ID of a published article: before the fix the node matcher returned no suggestion for it, after the fix the CKEditor 5 Linkit dialog suggests the article, while 39abc still returns nothing. A bare numeric ID now finds the entity as proposed.