diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 4cc6424..7bd9715 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -797,7 +797,7 @@ function template_preprocess_image(&$variables) { if (isset($variables[$key])) { // If the property has already been defined in the attributes, // do not override, including NULL. - if (array_key_exists($key, $variables['attributes'])) { + if (isset($variables['attributes'][$key]) || array_key_exists($key, $variables['attributes'])) { continue; } $variables['attributes'][$key] = $variables[$key]; diff --git a/core/lib/Drupal/Component/Assertion/Inspector.php b/core/lib/Drupal/Component/Assertion/Inspector.php index 9b04e33..78a9c3d 100644 --- a/core/lib/Drupal/Component/Assertion/Inspector.php +++ b/core/lib/Drupal/Component/Assertion/Inspector.php @@ -212,7 +212,7 @@ public static function assertAllHaveKey() { if (static::assertTraversable($traversable)) { foreach ($traversable as $member) { foreach ($args as $key) { - if (!array_key_exists($key, $member)) { + if (!(isset($member[$key]) || array_key_exists($key, $member))) { return FALSE; } } diff --git a/core/lib/Drupal/Component/Datetime/DateTimePlus.php b/core/lib/Drupal/Component/Datetime/DateTimePlus.php index b636262..51f36bb 100644 --- a/core/lib/Drupal/Component/Datetime/DateTimePlus.php +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php @@ -575,7 +575,7 @@ public static function checkArray($array) { $valid_time = TRUE; // Check for a valid date using checkdate(). Only values that // meet that test are valid. - if (array_key_exists('year', $array) && array_key_exists('month', $array) && array_key_exists('day', $array)) { + if (isset($array['year']) && isset($array['month']) && isset($array['day'])) { if (@checkdate($array['month'], $array['day'], $array['year'])) { $valid_date = TRUE; } @@ -583,7 +583,7 @@ public static function checkArray($array) { // Testing for valid time is reversed. Missing time is OK, // but incorrect values are not. foreach (['hour', 'minute', 'second'] as $key) { - if (array_key_exists($key, $array)) { + if (isset($array[$key]) || array_key_exists($key, $array)) { $value = $array[$key]; switch ($key) { case 'hour': diff --git a/core/lib/Drupal/Component/Utility/DiffArray.php b/core/lib/Drupal/Component/Utility/DiffArray.php index 825648e..1eea778 100644 --- a/core/lib/Drupal/Component/Utility/DiffArray.php +++ b/core/lib/Drupal/Component/Utility/DiffArray.php @@ -29,7 +29,7 @@ public static function diffAssocRecursive(array $array1, array $array2) { foreach ($array1 as $key => $value) { if (is_array($value)) { - if (!array_key_exists($key, $array2) || !is_array($array2[$key])) { + if (!is_array($array2[$key]) || !(isset($array2[$key]) || array_key_exists($key, $array2))) { $difference[$key] = $value; } else { @@ -39,7 +39,7 @@ public static function diffAssocRecursive(array $array1, array $array2) { } } } - elseif (!array_key_exists($key, $array2) || $array2[$key] !== $value) { + elseif (!(isset($array2[$key]) || array_key_exists($key, $array2)) || $array2[$key] !== $value) { $difference[$key] = $value; } } diff --git a/core/lib/Drupal/Component/Utility/NestedArray.php b/core/lib/Drupal/Component/Utility/NestedArray.php index c11d6a6..421a624 100644 --- a/core/lib/Drupal/Component/Utility/NestedArray.php +++ b/core/lib/Drupal/Component/Utility/NestedArray.php @@ -69,7 +69,7 @@ class NestedArray { public static function &getValue(array &$array, array $parents, &$key_exists = NULL) { $ref = &$array; foreach ($parents as $parent) { - if (is_array($ref) && array_key_exists($parent, $ref)) { + if (is_array($ref) && (isset($ref[$parent]) || array_key_exists($parent, $ref))) { $ref = &$ref[$parent]; } else { @@ -219,7 +219,7 @@ public static function setValue(array &$array, array $parents, $value, $force = public static function unsetValue(array &$array, array $parents, &$key_existed = NULL) { $unset_key = array_pop($parents); $ref = &self::getValue($array, $parents, $key_existed); - if ($key_existed && is_array($ref) && array_key_exists($unset_key, $ref)) { + if ($key_existed && is_array($ref) && (isset($ref[$unset_key]) || array_key_exists($unset_key, $ref))) { $key_existed = TRUE; unset($ref[$unset_key]); } diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index 9fea3df..8e1805a 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -92,7 +92,8 @@ public function getFilePath($name) { * {@inheritdoc} */ public function exists($name) { - return array_key_exists($name, $this->getAllFolders()); + $all_folders = $this->getAllFolders(); + return isset($all_folders[$name]) || array_key_exists($name, $all_folders); } /** diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index 1911d6a..41eef98 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -181,7 +181,7 @@ protected function createFieldSql($name, $spec) { } // $spec['default'] can be NULL, so we explicitly check for the key here. - if (array_key_exists('default', $spec)) { + if (isset($spec['default']) || array_key_exists('default', $spec)) { $sql .= ' DEFAULT ' . $this->escapeDefaultValue($spec['default']); } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index 4586d01..43e4701 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -328,7 +328,9 @@ protected function createFieldSql($name, $spec) { $sql .= ' NULL'; } } - if (array_key_exists('default', $spec)) { + + // $spec['default'] can be NULL, so we explicitly check for the key here. + if (isset($spec['default']) || array_key_exists('default', $spec)) { $default = $this->escapeDefaultValue($spec['default']); $sql .= " default $default"; } diff --git a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php index d999450..c1960a8 100644 --- a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php +++ b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php @@ -184,7 +184,7 @@ private function parseDefinition($id, $service, $file) $definition->setAbstract($service['abstract']); } - if (array_key_exists('deprecated', $service)) { + if (isset($service['deprecated']) || array_key_exists('deprecated', $service)) { $definition->setDeprecated(true, $service['deprecated']); } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 9d6b8d6..ffb5c5f 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -108,7 +108,7 @@ protected function initFieldValues(ContentEntityInterface $entity, array $values if (isset($values[$name])) { $entity->$name = $values[$name]; } - elseif (!array_key_exists($name, $values)) { + elseif (!(isset($values[$name]) || array_key_exists($name, $values))) { $entity->get($name)->applyDefaultValue(); } } diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index de77e09..7802bee 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -100,7 +100,7 @@ public function doCreate(array $values = []) { if (isset($values[$name])) { $entity->$name = $values[$name]; } - elseif (!array_key_exists($name, $values)) { + elseif (!(isset($values[$name]) || array_key_exists($name, $values))) { $entity->get($name)->applyDefaultValue(); } unset($values[$name]); diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 1172406..5a34c6d 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -651,7 +651,7 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value // https://www.drupal.org/node/1866330. // Default to the original entity language if not explicitly specified // otherwise. - if (!array_key_exists($this->defaultLangcodeKey, $values)) { + if (!(isset($values[$this->defaultLangcodeKey]) || array_key_exists($this->defaultLangcodeKey, $values))) { $values[$this->defaultLangcodeKey] = 1; } // If the 'default_langcode' flag is explicitly not set, we do not care diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index e53e84b..078d9d6 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -356,7 +356,7 @@ public function setSettings(array $settings) { * {@inheritdoc} */ public function getSetting($setting_name) { - if (array_key_exists($setting_name, $this->settings)) { + if (isset($this->settings[$setting_name]) || array_key_exists($setting_name, $this->settings)) { return $this->settings[$setting_name]; } else { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index f9922b9..cf2d4bd 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -175,13 +175,13 @@ public function setValue($values, $notify = TRUE) { // Support setting the field item with only one property, but make sure // values stay in sync if only property is passed. // NULL is a valid value, so we use array_key_exists(). - if (is_array($values) && array_key_exists('target_id', $values) && !isset($values['entity'])) { + if (is_array($values) && (isset($values['target_id']) || array_key_exists('target_id', $values)) && !isset($values['entity'])) { $this->onChange('target_id', FALSE); } - elseif (is_array($values) && !array_key_exists('target_id', $values) && isset($values['entity'])) { + elseif (is_array($values) && !(isset($values['target_id']) || array_key_exists('target_id', $values)) && isset($values['entity'])) { $this->onChange('entity', FALSE); } - elseif (is_array($values) && array_key_exists('target_id', $values) && isset($values['entity'])) { + elseif (is_array($values) && (isset($values['target_id']) || array_key_exists('target_id', $values)) && isset($values['entity'])) { // If both properties are passed, verify the passed values match. The // only exception we allow is when we have a new entity: in this case // its actual id and target_id will be different, due to the new entity @@ -328,10 +328,10 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { // We only display base plugins (e.g. 'default', 'views', ...) and not // entity type specific plugins (e.g. 'default:node', 'default:user', // ...). - if (array_key_exists($selection_group_id, $selection_plugins[$selection_group_id])) { + if (isset($selection_plugins[$selection_group_id][$selection_group_id]) || array_key_exists($selection_group_id, $selection_plugins[$selection_group_id])) { $handlers_options[$selection_group_id] = Html::escape($selection_plugins[$selection_group_id][$selection_group_id]['label']); } - elseif (array_key_exists($selection_group_id . ':' . $this->getSetting('target_type'), $selection_plugins[$selection_group_id])) { + elseif (isset($selection_plugins[$selection_group_id][$selection_group_id . ':' . $this->getSetting('target_type')]) || array_key_exists($selection_group_id . ':' . $this->getSetting('target_type'), $selection_plugins[$selection_group_id])) { $selection_group_plugin = $selection_group_id . ':' . $this->getSetting('target_type'); $handlers_options[$selection_group_plugin] = Html::escape($selection_plugins[$selection_group_id][$selection_group_plugin]['base_plugin_label']); } diff --git a/core/lib/Drupal/Core/Field/PluginSettingsBase.php b/core/lib/Drupal/Core/Field/PluginSettingsBase.php index 073bd2c..d0bd132 100644 --- a/core/lib/Drupal/Core/Field/PluginSettingsBase.php +++ b/core/lib/Drupal/Core/Field/PluginSettingsBase.php @@ -58,7 +58,7 @@ public function getSettings() { */ public function getSetting($key) { // Merge defaults if we have no value for the key. - if (!$this->defaultSettingsMerged && !array_key_exists($key, $this->settings)) { + if (!$this->defaultSettingsMerged && !(isset($this->settings[$key]) || array_key_exists($key, $this->settings))) { $this->mergeDefaults(); } return isset($this->settings[$key]) ? $this->settings[$key] : NULL; diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php index c9a93ff..8c49812 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php @@ -106,7 +106,7 @@ protected function prepareArguments(array $arguments) { $argument += ['required' => TRUE]; // Check if the argument is required and, if so, has been provided. if ($argument['required']) { - if (!array_key_exists($id, $arguments)) { + if (!(isset($arguments[$id]) || !array_key_exists($id, $arguments))) { // If the argument is required throw an exception. throw new \InvalidArgumentException("Argument '$id' expected by plugin '{$this->getPluginId()}' but not passed"); } @@ -115,14 +115,14 @@ protected function prepareArguments(array $arguments) { // Optional arguments require a 'default' value. // We check this even if the argument is provided by the caller, as we // want to fail fast here, i.e. at development time. - if (!array_key_exists('default', $argument)) { + if (!(isset($argument['default']) || !array_key_exists('default', $argument))) { // The plugin did not define a default, so throw a plugin exception, // not an invalid argument exception. throw new InvalidPluginDefinitionException("Default for argument '$id' expected by plugin '{$this->getPluginId()}' but not defined"); } // Use the default value if the argument is not passed in. - if (!array_key_exists($id, $arguments)) { + if (!(isset($arguments[$id]) || !array_key_exists($id, $arguments))) { $arguments[$id] = $argument['default']; } } diff --git a/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php b/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php index d6a6ca9..766665c 100644 --- a/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php @@ -18,14 +18,14 @@ class MemoryStorage extends StorageBase { * {@inheritdoc} */ public function has($key) { - return array_key_exists($key, $this->data); + return isset($this->data[$key]) || array_key_exists($key, $this->data); } /** * {@inheritdoc} */ public function get($key, $default = NULL) { - return array_key_exists($key, $this->data) ? $this->data[$key] : $default; + return (isset($this->data[$key]) || array_key_exists($key, $this->data)) ? $this->data[$key] : $default; } /** diff --git a/core/lib/Drupal/Core/Path/AliasWhitelist.php b/core/lib/Drupal/Core/Path/AliasWhitelist.php index 9286c95..2e0c144 100644 --- a/core/lib/Drupal/Core/Path/AliasWhitelist.php +++ b/core/lib/Drupal/Core/Path/AliasWhitelist.php @@ -92,7 +92,7 @@ public function get($offset) { return TRUE; } } - elseif (array_key_exists($offset, $this->storage)) { + elseif (isset($this->storage[$offset]) || array_key_exists($offset, $this->storage)) { return $this->resolveCacheMiss($offset); } } diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 243a9af..ad6ffc9 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -339,7 +339,7 @@ public static function preRenderAjaxForm($element) { 'options' => ['query' => []], 'dialogType' => 'ajax', ]; - if (array_key_exists('callback', $settings) && !isset($settings['url'])) { + if ((isset($settings['callback']) || array_key_exists('callback', $settings)) && !isset($settings['url'])) { $settings['url'] = Url::fromRoute(''); // Add all the current query parameters in order to ensure that we build // the same form on the AJAX POST requests. For example, diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index 63dcd47..6b2ca9e 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -195,7 +195,10 @@ protected function doGenerate(array $variables, array $defaults, array $tokens, // [ [ 0 => 'text', 1 => '/admin/config' ] ] foreach ($tokens as $token) { if ('variable' === $token[0]) { - if (!$optional || !array_key_exists($token[3], $defaults) || (isset($mergedParams[$token[3]]) && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]])) { + if (!$optional + || !(isset($defaults[$token[3]]) || array_key_exists($token[3], $defaults)) + || (isset($mergedParams[$token[3]]) + && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]])) { // check requirement if (!preg_match('#^' . $token[2] . '$#', $mergedParams[$token[3]])) { $message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]); diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index 52a4394..a8e1cf5 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -295,9 +295,7 @@ public function addConstraint($constraint_name, $options = NULL) { * @todo: Remove in https://www.drupal.org/node/1928868. */ public function offsetExists($offset) { - // PHP's array access does not work correctly with isset(), so we have to - // bake isset() in here. See https://bugs.php.net/bug.php?id=41727. - return array_key_exists($offset, $this->definition) && isset($this->definition[$offset]); + return isset($this->definition[$offset]); } /** diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php index 4f756da..9f28fe0 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php @@ -130,7 +130,7 @@ public function set($index, $value) { * {@inheritdoc} */ public function removeItem($index) { - if (isset($this->list) && array_key_exists($index, $this->list)) { + if (isset($this->list) && (isset($this->list[$index]) || array_key_exists($index, $this->list))) { // Remove the item, and reassign deltas. unset($this->list[$index]); $this->rekey($index); diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php index bc2ce5a..fe80bdf 100644 --- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php +++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php @@ -96,7 +96,7 @@ public function has($key) { // are not registered, just check the existence of the key in the registry. // Use array_key_exists() here since a NULL value indicates that the theme // hook exists but has not yet been requested. - return array_key_exists($key, $this->storage); + return isset($this->storage[$key]) || array_key_exists($key, $this->storage); } /** diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php index a020cdc..3b5e575 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php @@ -28,7 +28,7 @@ class ComplexDataConstraint extends Constraint { */ public function __construct($options = NULL) { // Allow skipping the 'properties' key in the options. - if (is_array($options) && !array_key_exists('properties', $options)) { + if (is_array($options) && !(isset($options['properties']) || array_key_exists('properties', $options))) { $options = ['properties' => $options]; } parent::__construct($options); diff --git a/core/modules/aggregator/src/Form/SettingsForm.php b/core/modules/aggregator/src/Form/SettingsForm.php index 48b2dfe..9d4aec5 100644 --- a/core/modules/aggregator/src/Form/SettingsForm.php +++ b/core/modules/aggregator/src/Form/SettingsForm.php @@ -156,7 +156,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Call buildConfigurationForm() on the active fetcher and parser. foreach (['fetcher', 'parser'] as $type) { $active = $config->get($type); - if (array_key_exists($active, $this->definitions[$type])) { + if (isset($this->definitions[$type][$active]) || array_key_exists($active, $this->definitions[$type])) { $instance = $this->managers[$type]->createInstance($active); if ($instance instanceof PluginFormInterface) { $form = $instance->buildConfigurationForm($form, $form_state); diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index b2d180a..4adb980 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -323,7 +323,7 @@ protected function validateVisibility(array $form, FormStateInterface $form_stat // All condition plugins use 'negate' as a Boolean in their schema. // However, certain form elements may return it as 0/1. Cast here to // ensure the data is in the expected type. - if (array_key_exists('negate', $values)) { + if (isset($values['negate']) || array_key_exists('negate', $values)) { $form_state->setValue(['visibility', $condition_id, 'negate'], (bool) $values['negate']); } diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index 7e6a7ca..c343b1d 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -225,7 +225,8 @@ protected function hasCreatedTime() { * TRUE if translatable field storage definition exists, FALSE otherwise. */ protected function checkFieldStorageDefinitionTranslatability($field_name) { - return array_key_exists($field_name, $this->fieldStorageDefinitions) && $this->fieldStorageDefinitions[$field_name]->isTranslatable(); + return (isset($this->fieldStorageDefinitions[$field_name]) || array_key_exists($field_name, $this->fieldStorageDefinitions)) + && $this->fieldStorageDefinitions[$field_name]->isTranslatable(); } /** diff --git a/core/modules/content_translation/src/Controller/ContentTranslationController.php b/core/modules/content_translation/src/Controller/ContentTranslationController.php index c18eab3..0438b7b 100644 --- a/core/modules/content_translation/src/Controller/ContentTranslationController.php +++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php @@ -160,7 +160,7 @@ public function overview(RouteMatchInterface $route_match, $entity_type_id = NUL ]; $links = &$operations['data']['#links']; - if (array_key_exists($langcode, $translations)) { + if (isset($translations[$langcode]) || array_key_exists($langcode, $translations)) { // Existing translation in the translation set: display status. $translation = $entity->getTranslation($langcode); $metadata = $manager->getTranslationMetadata($translation); diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index 78b3d60..e68b60d 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -552,11 +552,11 @@ public function getSetting($setting_name) { // @todo See getSettings() about potentially statically caching this. // We assume here that one call to array_key_exists() is more efficient // than calling getSettings() when all we need is a single setting. - if (array_key_exists($setting_name, $this->settings)) { + if (isset($this->settings[$setting_name]) || array_key_exists($setting_name, $this->settings)) { return $this->settings[$setting_name]; } $settings = $this->getSettings(); - if (array_key_exists($setting_name, $settings)) { + if (isset($settings[$setting_name]) || array_key_exists($setting_name, $settings)) { return $settings[$setting_name]; } else { diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index 0baa0cb..c4139d0 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -232,7 +232,7 @@ function file_test_file_url_alter(&$uri) { // Serve files with one of the CDN extensions from CDN 1, all others from // CDN 2. $pathinfo = pathinfo($path); - if (array_key_exists('extension', $pathinfo) && in_array($pathinfo['extension'], $cdn_extensions)) { + if ((isset($pathinfo['extension']) || array_key_exists('extension', $pathinfo)) && in_array($pathinfo['extension'], $cdn_extensions)) { $uri = FILE_URL_TEST_CDN_1 . '/' . $path; } else { diff --git a/core/modules/filter/src/Entity/FilterFormat.php b/core/modules/filter/src/Entity/FilterFormat.php index 9dbaa62..56b3b50 100644 --- a/core/modules/filter/src/Entity/FilterFormat.php +++ b/core/modules/filter/src/Entity/FilterFormat.php @@ -313,7 +313,7 @@ public function getHtmlRestrictions() { foreach ($intersection as $tag => $attributes) { // If the current tag is not whitelisted by the new filter, then // it's outside of the intersection. - if (!array_key_exists($tag, $new_restrictions['allowed'])) { + if (!(isset($new_restrictions['allowed'][$tag]) || array_key_exists($tag, $new_restrictions['allowed']))) { // The exception is the asterisk (which applies to all tags): it // does not need to be whitelisted by every filter in order to be // used; not every filter needs attribute restrictions on all tags. diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php index 735cfce..6aa4f8f 100644 --- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php +++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php @@ -263,7 +263,7 @@ public static function validateRequiredFields($element, FormStateInterface $form $image_field = NestedArray::getValue($form_state->getUserInput(), $parents); // We check for the array key, so that it can be NULL (like if the user // submits the form without using the "upload" button). - if (!array_key_exists($field, $image_field)) { + if (!(isset($image_field[$field]) || !array_key_exists($field, $image_field))) { return; } } diff --git a/core/modules/language/src/Form/NegotiationBrowserForm.php b/core/modules/language/src/Form/NegotiationBrowserForm.php index 5535fe0..c82f466 100644 --- a/core/modules/language/src/Form/NegotiationBrowserForm.php +++ b/core/modules/language/src/Form/NegotiationBrowserForm.php @@ -158,7 +158,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $mappings = $form_state->getValue('mappings'); foreach ($mappings as $key => $data) { // Make sure browser_langcode is unique. - if (array_key_exists($data['browser_langcode'], $unique_values)) { + if (isset($unique_values[$data['browser_langcode']]) || array_key_exists($data['browser_langcode'], $unique_values)) { $form_state->setErrorByName('mappings][new_mapping][browser_langcode', $this->t('Browser language codes must be unique.')); } elseif (preg_match('/[^a-z\-]/', $data['browser_langcode'])) { @@ -172,7 +172,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $data = $form_state->getValue('new_mapping'); if (!empty($data['browser_langcode'])) { // Make sure browser_langcode is unique. - if (array_key_exists($data['browser_langcode'], $unique_values)) { + if (isset($unique_values[$data['browser_langcode']]) || array_key_exists($data['browser_langcode'], $unique_values)) { $form_state->setErrorByName('mappings][' . $key . '][browser_langcode', $this->t('Browser language codes must be unique.')); } elseif (preg_match('/[^a-z\-]/', $data['browser_langcode'])) { diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php index 9218899..7af4ded 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php @@ -91,8 +91,8 @@ public static function create(ContainerInterface $container, array $configuratio */ public function getLangcode(Request $request = NULL) { $langcode = $request->query->get(static::QUERY_PARAMETER); - - $language_enabled = array_key_exists($langcode, $this->languageManager->getLanguages()); + $languages = $this->languageManager->getLanguages(); + $language_enabled = isset($languages[$langcode]) || array_key_exists($langcode, $languages); return $language_enabled ? $langcode : NULL; } diff --git a/core/modules/locale/src/LocaleProjectStorage.php b/core/modules/locale/src/LocaleProjectStorage.php index 05faa17..8253ef0 100644 --- a/core/modules/locale/src/LocaleProjectStorage.php +++ b/core/modules/locale/src/LocaleProjectStorage.php @@ -60,7 +60,7 @@ public function getMultiple(array $keys) { $values[$key] = $this->cache[$key]; } // Load the value if we don't have an explicit NULL value. - elseif (!array_key_exists($key, $this->cache)) { + elseif (!(isset($this->cache[$key]) || array_key_exists($key, $this->cache))) { $load[] = $key; } } diff --git a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php index 1d68f35..2d3e0ed 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php +++ b/core/modules/migrate/src/Plugin/migrate/process/StaticMap.php @@ -124,7 +124,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable } $new_value = NestedArray::getValue($this->configuration['map'], $new_value, $key_exists); if (!$key_exists) { - if (array_key_exists('default_value', $this->configuration)) { + if (isset($this->configuration['default_value']) || array_key_exists('default_value', $this->configuration)) { if (!empty($this->configuration['bypass'])) { throw new MigrateException('Setting both default_value and bypass is invalid.'); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php b/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php index 5d99955..3ef50e1 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php +++ b/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php @@ -128,7 +128,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $new_row = new Row($new_value, []); $migrate_executable->processRow($new_row, $this->configuration['process']); $destination = $new_row->getDestination(); - if (array_key_exists('key', $this->configuration)) { + if (isset($this->configuration['key']) || array_key_exists('key', $this->configuration)) { $key = $this->transformKey($key, $migrate_executable, $new_row); } $return[$key] = $destination; diff --git a/core/modules/node/src/Plugin/views/wizard/Node.php b/core/modules/node/src/Plugin/views/wizard/Node.php index 34d4bcf..a58e1e8 100644 --- a/core/modules/node/src/Plugin/views/wizard/Node.php +++ b/core/modules/node/src/Plugin/views/wizard/Node.php @@ -245,7 +245,7 @@ protected function buildFilters(&$form, FormStateInterface $form_state) { // that is created by the Standard install profile in core and also // commonly used by contrib modules; thus, it is most likely to be // associated with the "main" free-tagging vocabulary on the site. - if (array_key_exists('field_tags', $tag_fields)) { + if (isset($tag_fields['field_tags']) || array_key_exists('field_tags', $tag_fields)) { $tag_field_name = 'field_tags'; } else { diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 8d43298..c6c8a7b 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -114,7 +114,7 @@ function rdf_get_namespaces() { foreach (\Drupal::moduleHandler()->getImplementations('rdf_namespaces') as $module) { $function = $module . '_rdf_namespaces'; foreach ($function() as $prefix => $namespace) { - if (array_key_exists($prefix, $namespaces) && $namespace !== $namespaces[$prefix]) { + if ((isset($namespaces[$prefix]) || array_key_exists($prefix, $namespaces)) && $namespace !== $namespaces[$prefix]) { throw new Exception(t('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', ['@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix]])); } else { diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 83d7feb..6a202f7 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -58,7 +58,8 @@ function simpletest_js_alter(&$javascript, AttachedAssetsInterface $assets) { // Since SimpleTest is a special use case for the table select, stick the // SimpleTest JavaScript above the table select. $simpletest = drupal_get_path('module', 'simpletest') . '/simpletest.js'; - if (array_key_exists($simpletest, $javascript) && array_key_exists('core/misc/tableselect.js', $javascript)) { + if ((isset($javascript[$simpletest]) || array_key_exists($simpletest, $javascript)) + && (isset($javascript['core/misc/tableselect.js']) || array_key_exists('core/misc/tableselect.js', $javascript))) { $javascript[$simpletest]['weight'] = $javascript['core/misc/tableselect.js']['weight'] - 1; } } diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php index 65fdc51..a94f622 100644 --- a/core/modules/system/src/Plugin/views/field/BulkForm.php +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php @@ -250,7 +250,8 @@ public function viewsForm(&$form, FormStateInterface $form_state) { // Add the tableselect javascript. $form['#attached']['library'][] = 'core/drupal.tableselect'; - $use_revision = array_key_exists('revision', $this->view->getQuery()->getEntityTableInfo()); + $table_info = $this->view->getQuery()->getEntityTableInfo(); + $use_revision = isset($table_info['revision']) || array_key_exists('revision', $table_info); // Only add the bulk form options and buttons if there are results. if (!empty($this->view->result)) { diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module index 040e40a..26f73b2 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -270,7 +270,7 @@ function common_test_page_attachments_alter(array &$page) { */ function common_test_js_settings_alter(&$settings, AttachedAssetsInterface $assets) { // Modify an existing setting. - if (array_key_exists('pluralDelimiter', $settings)) { + if (isset($settings['pluralDelimiter']) || array_key_exists('pluralDelimiter', $settings)) { $settings['pluralDelimiter'] = '☃'; } diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 16983d6..98e4061 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -102,7 +102,7 @@ function template_preprocess_toolbar(&$variables) { 'links' => $element[$key]['tray'], 'attributes' => new Attribute($attributes), ]; - if (array_key_exists('#heading', $element[$key]['tray'])) { + if (isset($element[$key]['tray']['#heading']) || array_key_exists('#heading', $element[$key]['tray'])) { $variables['trays'][$key]['label'] = $element[$key]['tray']['#heading']; } } diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 3744fea..8c29657 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -772,7 +772,7 @@ public function getOption($option) { return $this->default_display->getOption($option); } - if (array_key_exists($option, $this->options)) { + if (isset($this->options[$option]) || array_key_exists($option, $this->options)) { return $this->options[$option]; } } diff --git a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php index ccf40f6..7e79bb8 100644 --- a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php +++ b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php @@ -341,7 +341,7 @@ protected function buildExtra($info, &$arguments, $table, SelectInterface $selec // Figure out the table name. Remember, only use aliases provided // if at all possible. $join_table = ''; - if (!array_key_exists('table', $info)) { + if (!(isset($info['table']) || array_key_exists('table', $info))) { $join_table = $table['alias'] . '.'; } elseif (isset($info['table'])) { diff --git a/core/modules/views/src/Plugin/views/join/Subquery.php b/core/modules/views/src/Plugin/views/join/Subquery.php index f407ffc..579a7f9 100644 --- a/core/modules/views/src/Plugin/views/join/Subquery.php +++ b/core/modules/views/src/Plugin/views/join/Subquery.php @@ -60,7 +60,7 @@ public function buildJoin($select_query, $table, $view_query) { // Figure out the table name. Remember, only use aliases provided // if at all possible. $join_table = ''; - if (!array_key_exists('table', $info)) { + if (!(isset($info['table']) || array_key_exists('table', $info))) { $join_table = $table['alias'] . '.'; } elseif (isset($info['table'])) { diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index ab056f5..cee232a 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -310,7 +310,7 @@ public function addRelationship($alias, JoinPluginBase $join, $base, $link_point if (empty($link_point)) { $link_point = $this->view->storage->get('base_table'); } - elseif (!array_key_exists($link_point, $this->relationships)) { + elseif (!(isset($this->relationships[$link_point]) || array_key_exists($link_point, $this->relationships))) { return FALSE; } @@ -429,7 +429,7 @@ public function queueTable($table, $relationship = NULL, JoinPluginBase $join = $relationship = $this->view->storage->get('base_table'); } - if (!array_key_exists($relationship, $this->relationships)) { + if (!(isset($this->relationships[$relationship]) || array_key_exists($relationship, $this->relationships))) { return FALSE; } @@ -538,7 +538,7 @@ public function ensureTable($table, $relationship = NULL, JoinPluginBase $join = return $this->tables[$relationship][$table]['alias']; } - if (!array_key_exists($relationship, $this->relationships)) { + if (!(isset($this->relationships[$relationship]) || array_key_exists($relationship, $this->relationships))) { return FALSE; } @@ -608,7 +608,7 @@ protected function ensurePath($table, $relationship = NULL, $join = NULL, $trace $relationship = $this->view->storage->get('base_table'); } - if (!array_key_exists($relationship, $this->relationships)) { + if (!(isset($this->relationships[$relationship]) || array_key_exists($relationship, $this->relationships))) { return FALSE; } diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 09a7aad..c9bf217 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -384,7 +384,7 @@ function simpletest_script_parse_args() { while ($arg = array_shift($_SERVER['argv'])) { if (preg_match('/--(\S+)/', $arg, $matches)) { // Argument found. - if (array_key_exists($matches[1], $args)) { + if (isset($args[$matches[1]]) || array_key_exists($matches[1], $args)) { // Argument found in list. $previous_arg = $matches[1]; if (is_bool($args[$previous_arg])) {