Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Theme / Registry.php
index a0af70261cbef14161bc05b84e9399fa5d1acfca..7cf4b3c43666f15c956f292ae8b113c94c2a9f70 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Drupal\Core\Theme;
 
+use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\DestructableInterface;
@@ -565,10 +566,18 @@ class Registry implements DestructableInterface {
           $info['preprocess functions'] = array_merge($cache[$hook]['preprocess functions'], $info['preprocess functions']);
         }
         $result[$hook]['preprocess functions'] = $info['preprocess functions'];
+
+        // If a theme implementation definition provides both 'template' and
+        // 'function', the 'function' will be used. In this case, if the new
+        // result provides a 'template' value, any existing 'function' value
+        // must be removed for the override to be called.
+        if (isset($result[$hook]['template'])) {
+          unset($cache[$hook]['function']);
+        }
       }
 
       // Merge the newly created theme hooks into the existing cache.
-      $cache = $result + $cache;
+      $cache = NestedArray::mergeDeep($cache, $result);
     }
 
     // Let themes have variable preprocessors even if they didn't register a