Gutenberg: getEntityRecord returns null instead of undefined when an entity does not exist.

Created on 3 Sep 2020  路  2Comments  路  Source: WordPress/gutenberg

Describe the bug
in Gutenberg 8.8 getEntityRecord and it's related functions ( getMedia etc. ) functions would return undefined when an entity didn't exist.

In Gutenberg 8.9 this now returns null. This is a backwards incompatible change as the recommended method by eslint to check for undefined is to do typeof value === "undefined" which returns false for null.

This will cause any plugin that previously made this check to start throwing errors as they'll be attempting property access on null. This can even cause the entire editor to crash, see https://github.com/Yoast/wordpress-seo/issues/15989.

To reproduce
Steps to reproduce the behavior:

  1. Install Yoast SEO 14.9
  2. Install Gutenberg 8.9
  3. Visit a post in the editor that has a featured image set
  4. See that the entire editor doesn't load.
  5. Install Gutenberg 8.8.
  6. See that no errors occur.

Expected behavior
Backwards incompatible changes should not be made to functions without proper notice and deprecation.

Editor version (please complete the following information):

  • WordPress version: 5.5.1
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? Gutenberg plugin
  • If the Gutenberg plugin is installed, which version is it? 8.9

Additional context

[Status] In Progress [Type] Bug

All 2 comments

Issue was identified and reported by others too on https://github.com/WordPress/gutenberg/issues/25033

Thanks so much for the swift response! I can confirm that 8.9.1 solved the issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasmussen picture jasmussen  路  3Comments

aaronjorbin picture aaronjorbin  路  3Comments

youknowriad picture youknowriad  路  3Comments

nylen picture nylen  路  3Comments

ellatrix picture ellatrix  路  3Comments