Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293292

entityQuery: When compared against an array, such as categories condition in webform, Drupal crashes

$
0
0

Problem/Motivation

There are two problems here, both of them in Drupal\Core\Config\Entity\Query\Condition.php.

This occurs under the condition that there are array values stored for a property in a config entity. In order to match the comparison correctly, the entity query system needs modification.

  1. There's a conversion to lower case that fails since it can't take an array as input.
  2. There's no comparison of a single value against an array value. The opposite exists, there a comparison with $condition['value'], but it matches the opposite, comparing an array in the condition with a mixed value in entity config.

The error given is:
TypeError: mb_strtolower(): Argument #1 ($string) must be of type string, array given in mb_strtolower() (line 174 of core/lib/Drupal/Core/Config/Entity/Query/Condition.php). Drupal\Core\Config\Entity\Query\Condition->match(Array, Array) (Line: 145)

Steps to reproduce

  1. Install webform and import the sample form attached, notice there are two categories present in the config.
  2. Set up a module that extracts entities from webform, filtered by the presence of a category. Sample code is given below.

Comparison code:

    $webforms = \Drupal::entityQuery('webform')
      ->accessCheck(FALSE)
      ->condition('categories', 'sample_category_1')
      ->execute();

Proposed resolution

When there's a match against the array value in entity config, the entityQuery should return all matching entities.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet


Viewing all articles
Browse latest Browse all 293292

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>