Problem/Motivation

Visiting /admin/structure/display-modes/view there are a number of depreciation messages:
Deprecated function: strnatcasecmp(): Passing null to parameter #2 ($string2) of type string is deprecated in Drupal\Core\Entity\EntityDisplayModeBase::sort() (line 72 of core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php).

Steps to reproduce

as above.

Proposed resolution

Could be a data issue - ie why are null entries being passed in?
See https://www.drupal.org/project/drupal/issues/3605760 for related issue

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#5 issue_3605761.patch483 bytesjons

Comments

jons created an issue. See original summary.

jons’s picture

Status: Active » Needs review

The data issue can most-likely be resolved by clearing the cache tables eg cache_entity;

The code (core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php) can be fixed with changing
$type_order = strnatcasecmp($a_type, $b_type);
to
$type_order = strnatcmp(mb_strtolower($a_type), mb_strtolower($b_type));

dcam’s picture

Category: Bug report » Support request
Status: Needs review » Fixed

This was an issue resulting from badly corrupted configuration, one that was potentially caused by human tampering as I explained in #3605760: On cache-clear: [warning] Undefined array key 1 EntityDisplayRepository.php:115. The source of this issue is the targetEntityType key of the configuration was NULL. That's something that shouldn't happen in the first place because that key is not nullable per its schema.

Deleting the offending configuration is the correct course of action.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

jons’s picture

Status: Fixed » Needs review
StatusFileSize
new483 bytes

patch for existing core code issue attached

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

As mentioned in #3 this appears to be user error so not sure there’s anything to actually fix here.

jons’s picture

Hi @smustgrave - its because, irrespective of the way it manifested itself, there is deprecated code here which is fixed in patch