Skip to content
Snippets Groups Projects
Unverified Commit bc8a19c8 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3488179 by phenaproxima, thejimbirch:...

Issue #3488179 by phenaproxima, thejimbirch: RecipeConfigurator::getIncludedRecipe() should statically cache recipe objects to avoid performance problems
parent f39f9236
No related branches found
No related tags found
11 merge requests!11197Issue #3506427 by eduardo morales alberti: Remove responsive_image.ajax from hook,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!10786Issue #3490579 by shalini_jha, mstrelan: Add void return to all views...,!10210Issue #3487907: Drupal.displace() use getComputedStyle() for hidden chk.,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation
...@@ -133,15 +133,13 @@ public function describeAll(): array { ...@@ -133,15 +133,13 @@ public function describeAll(): array {
* constraints. * constraints.
*/ */
public function collectAll(InputCollectorInterface $collector, array &$processed = []): void { public function collectAll(InputCollectorInterface $collector, array &$processed = []): void {
if (is_array($this->values)) {
throw new \LogicException('Input values cannot be changed once they have been set.');
}
// Don't bother collecting values for a recipe we've already seen. // Don't bother collecting values for a recipe we've already seen.
if (in_array($this->prefix, $processed, TRUE)) { if (in_array($this->prefix, $processed, TRUE)) {
return; return;
} }
if (is_array($this->values)) {
throw new \LogicException('Input values cannot be changed once they have been set.');
}
// First, collect values for the recipe's dependencies. // First, collect values for the recipe's dependencies.
/** @var \Drupal\Core\Recipe\Recipe $dependency */ /** @var \Drupal\Core\Recipe\Recipe $dependency */
foreach ($this->dependencies->recipes as $dependency) { foreach ($this->dependencies->recipes as $dependency) {
......
...@@ -15,6 +15,13 @@ final class RecipeConfigurator { ...@@ -15,6 +15,13 @@ final class RecipeConfigurator {
*/ */
public readonly array $recipes; public readonly array $recipes;
/**
* A cache of already-loaded recipes, keyed by path.
*
* @var \Drupal\Core\Recipe\Recipe[]
*/
private static array $cache = [];
/** /**
* @param string[] $recipes * @param string[] $recipes
* A list of recipes for a recipe to apply. The recipes will be applied in * A list of recipes for a recipe to apply. The recipes will be applied in
...@@ -56,8 +63,11 @@ public static function getIncludedRecipe(string $include_path, string $name): Re ...@@ -56,8 +63,11 @@ public static function getIncludedRecipe(string $include_path, string $name): Re
$path = $include_path . "/$name/recipe.yml"; $path = $include_path . "/$name/recipe.yml";
} }
if (array_key_exists($path, static::$cache)) {
return static::$cache[$path];
}
if (file_exists($path)) { if (file_exists($path)) {
return Recipe::createFromDirectory(dirname($path)); return static::$cache[$path] = Recipe::createFromDirectory(dirname($path));
} }
$search_path = dirname($path, 2); $search_path = dirname($path, 2);
throw new UnknownRecipeException($name, $search_path, sprintf("Can not find the %s recipe, search path: %s", $name, $search_path)); throw new UnknownRecipeException($name, $search_path, sprintf("Can not find the %s recipe, search path: %s", $name, $search_path));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment