You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/wp-includes/class-wp-scripts.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1000,9 +1000,14 @@ private function get_eligible_loading_strategy( $handle ) {
1000
1000
* @param string $handle The script handle.
1001
1001
* @param string[]|null $eligible_strategies Optional. The list of strategies to filter. Default null.
1002
1002
* @param array<string, true> $checked Optional. An array of already checked script handles, used to avoid recursive loops.
1003
+
* @param array<string, string[]> $stored_results Optional. An array of already computed eligible loading strategies by handle, used to increase performance in large dependency lists.
1003
1004
* @return string[] A list of eligible loading strategies that could be used.
'Expected "high" indicates that the cached `$stored_results` entry for D was used instead of recalculating.'
1496
+
);
1497
+
}
1438
1498
/**
1439
1499
* Tests that printing a script without enqueueing has the same output as when it is enqueued.
1440
1500
*
@@ -1533,7 +1593,72 @@ public function test_loading_strategy_with_valid_blocking_registration() {
1533
1593
$expected = str_replace( "'", '"', $expected );
1534
1594
$this->assertSame( $expected, $output, 'Scripts registered with no strategy assigned, and who have no dependencies, should have no loading strategy attributes printed.' );
1535
1595
}
1596
+
/**
1597
+
* @ticket 64194
1598
+
*
1599
+
* Tests that `WP_Scripts::filter_eligible_strategies()` correctly reuses cached results
1600
+
* for shared dependencies in a diamond-shaped dependency graph.
1601
+
*
1602
+
* Dependency Graph:
1603
+
*
1604
+
* D <- [B, C]
1605
+
* B <- [A]
1606
+
* C <- [A]
1607
+
* A <- []
1608
+
*
1609
+
* In this scenario, both B and C depend on D, and A depends on both B and C.
1610
+
* The goal is to confirm that when `$stored_results` already contains an entry for D,
1611
+
* the cached value is reused instead of recalculating the strategies for D multiple times.
0 commit comments