diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php index b0a325f..e6d2d52 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php @@ -39,7 +39,7 @@ public function compile($configs) { if (is_array($condition['value'])) { $condition['value'] = array_map('Drupal\Component\Utility\Unicode::strtolower', $condition['value']); } - else { + elseif (!is_bool($condition['value'])) { $condition['value'] = Unicode::strtolower($condition['value']); } @@ -161,7 +161,9 @@ protected function matchArray(array $condition, array $data, array $needs_matchi protected function match(array $condition, $value) { if (isset($value)) { // We always want a case-insensitive match. - $value = Unicode::strtolower($value); + if (!is_bool($value)) { + $value = Unicode::strtolower($value); + } switch ($condition['operator']) { case '=': diff --git a/core/lib/Drupal/Core/Entity/Query/QueryInterface.php b/core/lib/Drupal/Core/Entity/Query/QueryInterface.php index d7110ca..5c32717 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryInterface.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryInterface.php @@ -46,9 +46,9 @@ public function getEntityType(); * @endcode * * @param $value - * The value for $field. In most cases, this is a scalar. For more complex - * options, it is an array. The meaning of each element in the array is - * dependent on $operator. + * The value for $field. In most cases, this is a scalar and it's treated as + * case-insensitive. For more complex options, it is an array. The meaning + * of each element in the array is dependent on $operator. * @param $operator * Possible values: * - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS', diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index 2205942..ccfc043 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; +use Drupal\Core\Config\Entity\ConfigStorageController; use Drupal\Core\Datetime\Date; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Datetime\DrupalDateTime; @@ -42,19 +43,29 @@ protected $dateService; /** + * The date format storage controller. + * + * @var \Drupal\Core\Config\Entity\ConfigStorageController + */ + protected $dateFormatStorage; + + /** * Constructs a new date format form. * * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. * @param \Drupal\Core\Datetime\Date $date_service * The date service. + * @param \Drupal\Core\Config\Entity\ConfigStorageController $date_format_storage + * The date format storage controller. */ - public function __construct(QueryFactory $query_factory, Date $date_service) { + public function __construct(QueryFactory $query_factory, Date $date_service, ConfigStorageController $date_format_storage) { $date = new DrupalDateTime(); $this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP; $this->queryFactory = $query_factory; $this->dateService = $date_service; + $this->dateFormatStorage = $date_format_storage; } /** @@ -63,7 +74,8 @@ public function __construct(QueryFactory $query_factory, Date $date_service) { public static function create(ContainerInterface $container) { return new static( $container->get('entity.query'), - $container->get('date') + $container->get('date'), + $container->get('entity.manager')->getStorageController('date_format') ); } @@ -183,16 +195,12 @@ public function validate(array $form, array &$form_state) { // The machine name field should already check to see if the requested // machine name is available. Regardless of machine_name or human readable // name, check to see if the provided pattern exists. - $format = trim($form_state['values']['date_format_pattern']); - $formats = $this->queryFactory - ->get($this->entity->entityType()) - ->condition('pattern.' . $this->patternType, $format) - ->execute(); - - // Exclude the current format. - unset($formats[$this->entity->id()]); - if (!empty($formats)) { - form_set_error('date_format_pattern', t('This format already exists. Enter a unique format string.')); + $pattern = trim($form_state['values']['date_format_pattern']); + foreach ($this->dateFormatStorage->loadMultiple() as $format) { + if ($format->getPattern() == $pattern) { + form_set_error('date_format_pattern', t('This format already exists. Enter a unique format string.')); + continue; + } } }