Closed CallumK-Enigma closed 6 days ago
Hi, thanks for reaching out! I haven’t been able to replicate the revisions being returned when using .search()
. However, please note that nested entries are also returned by default when you query entries in Craft 5. There’s more info on that here: https://craftcms.com/docs/5.x/system/searching.html#searching-nested-elements.
Can you first try changing your query to only search through entries that belong to e.g. any section (craft.entries().section('*').search(searchQuery).orderBy('score').all()
) and see if that returns the desired results?
Hi, @i-just
Looks like the suggested was exactly the issue! Resolved now!
Great news! Glad to hear it’s all working as expected.
What happened?
Description
After upgrading from Craft CMS 4.5.11.1 to 5.5.0.1 I have observed some weird behaviour with the
craft.entries()
twig query. The query appears to return a number of entries, some full entries, others with no data other than an ID. Checking those ID's in theentries
table, theprimaryOwnerId
links to a record in theelements
table that is an old revision.This has occurred off of the back of a separate issue which I found had been addressed [https://github.com/craftcms/cms/issues/16032] when updating the Craft CMS version.
Steps to reproduce
{% set entries = craft.entries().search(searchQuery).orderBy('score').all() %}
Expected behavior
Query will return an array of fully populated Entry objects relevant to the query
Actual behavior
Query returns an array of Entry objects, some of which are fully populated with the expected data. Others have nothing but an ID, and appear to tie to an old revision on an entry through the the
primaryOwnerId
link to the entries table.Craft CMS version
5.5.0.1
PHP version
8.2.22
Operating system and version
Linux 5.15.153.1-microsoft-standard-WSL2
Database type and version
MariaDB 10.6.18
Image driver and version
GD 8.2.22
Installed plugins and versions