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
- Use a Linkit profile with the Content (node) matcher.
- In the link dialog, type the numeric ID of an existing, published node.
- 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
EntityMatchertest with a numeric search string)
Patch attached, against 7.x.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3630280 after, result null.png | 48.97 KB | csakiistvan |
| #6 | 3630280 after, with result.png | 55.9 KB | csakiistvan |
| #6 | 3630280 before.png | 90.23 KB | csakiistvan |
| linkit-entity-id-search.patch | 861 bytes | u_tiwari |
Issue fork linkit-3630280
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
Comment #2
ishfaqafridi85 commentedI will check the patch locally and add test coverage for searching by entity ID.
Comment #4
ishfaqafridi85 commentedAdded 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.
Comment #5
csakiistvanComment #6
csakiistvan✅ 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
39abcstill returns nothing. A bare numeric ID now finds the entity as proposed.