Entity reference media view works perfectly, autocomplete using same view fails

Created on 15 February 2023, over 1 year ago

Problem/Motivation

Hi, I'm trying to have an entityqueue of media items, but as far as I can tell, it appears impossible. Have entityqueues been tested with media entities? I notice on the module page β†’ they are not listed as being supported (though it does say "etc" which made me think they were.)

Using the default method wasn't working for us, and since I could not figure out what was actually being searched using that method (referenced filename?!?) I switched the "Reference method" to views so that I would at least know what to put into the autocomplete.

I created a view that works perfectly, it listed one field (field_title) for each media item. I adjusted the Entity Reference List "Search fields" to search by field_title, and confirmed results were showing as expected in the Preview area of the view.

After setting my entityqueue to use this view, the autocomplete on the Queue items page spins for about 1 second after text is entered, then stop spinning, with no matches but also no errors, making it appear as though there was no match in the system.

I confirmed that I have plenty of media items that should match my query, so I enabled the dblog module, to see if maybe there was a hidden problem during the autocomplete.

The following errors appeared in the log:

Notice: Undefined index: #row in Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection->stripAdminAndAnchorTagsFromResults() (line 287 of drupal9/docroot/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php) 
Notice: Trying to get property '_entity' of non-object in Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection->stripAdminAndAnchorTagsFromResults() (line 287 of drupal9/docroot/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php) 
Error: Call to a member function bundle() on null in Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection->stripAdminAndAnchorTagsFromResults() (line 288 of /Users/jlampton/Sites/mtc/abag/drupal9/docroot/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php) 

I then switched back to the "Default" Reference method to see if the same errors appeared in the logs, but they did not. The spinner behaves the same way: spins, then stops 1 second later with no matches but also no errors - but there are also no errors in the log.

I then tried using the media ID for matching, thinking the problem might be that I was using a field and not a native property of the media entity, but that also failed with the same three errors as above.

Steps to reproduce

1) Create a entity reference view of media items,
2) add a field to the view, of Media: ID
3) use Media: ID as the "Search field" under format settings
3) Create an entityqueue of media items using this view
4) attempt to add any item to this queue using the Media: ID
5) get no matches, and errors in the log

Proposed resolution

Fix the autocomplete to run the same query as the view?

Remaining tasks

TBD

User interface changes

none

API changes

TBD

Data model changes

TBD

πŸ› Bug report
Status

Active

Version

1.6

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jenlampton

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

Comments & Activities

Production build 0.71.5 2024