getEntityRecords() for 'attachment' post type no longer works with Wordpress 5.6 #27771
Labels
Backwards Compatibility
Issues or PRs that impact backwards compatability
Good First Issue
An issue that's suitable for someone looking to contribute for the first time
[Package] Data
/packages/data
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Describe the bug
I have been making use of getEntityRecords() to fetch image data to display in some custom Gutenberg blocks. They worked fine until I upgraded to Wordpress 5.6. Now when I make calls with getEntityRecords() I get the following errors:
"Uncaught TypeError: fe(...) is null"
"Uncaught (in promise) TypeError: fe(...) is null"
However, I can successfully fetch image data by using getMedia(). This was the behavior I experienced on my live and staging sites. I deactivated all plugins and changed to Twentytwentyone theme and still had the issue. So I installed a fresh copy of Wordpress locally and went through the following steps, which produced the error as well.
To reproduce
Steps to reproduce the behavior:
6
)wp.data.select('core').getEntityRecords('postType', 'attachment', { include: 6 })
wp.data.select('core').getMedia(6)
(you'll likely get 'undefined' the first time while it's fetching the media item, but if you re-enter you should be able to see the details for that image)Expected behavior
I expected to be able to continue using getEntityRecords() within my custom blocks like I did before. I noticed that a similar error would occur fetching pages (e.g.
wp.data.select('core').getEntityRecords('postType', 'page', { include: 3912 } )
) but if I passed the post_id as a string in the query parameter it works (e.g.wp.data.select('core').getEntityRecords('postType', 'page', { include: '3912' } )
. However, passing the attachment ID as a string always returnsnull
Screenshots
![Screen Shot 2020-12-16 at 13 31 47](https://user-images.githubusercontent.com/5252550/102408963-30731680-3fa3-11eb-9c12-6762c63541e7.png)
Firefox console error:
Chrome console error, slightly different message:
![Screen Shot 2020-12-16 at 13 54 12](https://user-images.githubusercontent.com/5252550/102411206-6ebe0500-3fa6-11eb-8be9-d851c0bd205a.png)
This screenshot shows the successful getMedia() call for the same image id:
![Screen Shot 2020-12-16 at 13 54 43](https://user-images.githubusercontent.com/5252550/102411260-83020200-3fa6-11eb-80b4-44c591a3c171.png)
Editor version (please complete the following information):
The text was updated successfully, but these errors were encountered: