Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Component / Utility / NestedArray.php
index 36df7c7b1f04566e3e7dd07ad640a5870ac44c37..86c73099ebd9b6c4fd09f5f910207808d7218da8 100644 (file)
@@ -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 @@ class NestedArray {
   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]);
     }