Changeset 61176 for trunk/src/wp-includes/class-wp-scripts.php
- Timestamp:
- 11/07/2025 06:11:24 AM (4 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-scripts.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-scripts.php
r60948 r61176 998 998 * @since 6.3.0 999 999 * 1000 * @param string $handle The script handle. 1001 * @param string[]|null $eligible_strategies Optional. The list of strategies to filter. Default null. 1002 * @param array<string, true> $checked Optional. An array of already checked script handles, used to avoid recursive loops. 1000 * @param string $handle The script handle. 1001 * @param string[]|null $eligible_strategies Optional. The list of strategies to filter. Default null. 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. 1004 1005 */ 1005 private function filter_eligible_strategies( $handle, $eligible_strategies = null, $checked = array() ) { 1006 private function filter_eligible_strategies( $handle, $eligible_strategies = null, $checked = array(), array &$stored_results = array() ) { 1007 if ( isset( $stored_results[ $handle ] ) ) { 1008 return $stored_results[ $handle ]; 1009 } 1010 1006 1011 // If no strategies are being passed, all strategies are eligible. 1007 1012 if ( null === $eligible_strategies ) { … … 1054 1059 } 1055 1060 1056 $eligible_strategies = $this->filter_eligible_strategies( $dependent, $eligible_strategies, $checked );1057 } 1058 1061 $eligible_strategies = $this->filter_eligible_strategies( $dependent, $eligible_strategies, $checked, $stored_results ); 1062 } 1063 $stored_results[ $handle ] = $eligible_strategies; 1059 1064 return $eligible_strategies; 1060 1065 } … … 1067 1072 * @see WP_Script_Modules::get_highest_fetchpriority_with_dependents() 1068 1073 * 1069 * @param string $handle Script module ID. 1070 * @param array<string, true> $checked Optional. An array of already checked script handles, used to avoid recursive loops. 1074 * @param string $handle Script module ID. 1075 * @param array<string, true> $checked Optional. An array of already checked script handles, used to avoid recursive loops. 1076 * @param array<string, string> $stored_results Optional. An array of already computed max priority by handle, used to increase performance in large dependency lists. 1071 1077 * @return string|null Highest fetch priority for the script and its dependents. 1072 1078 */ 1073 private function get_highest_fetchpriority_with_dependents( string $handle, array $checked = array() ): ?string { 1079 private function get_highest_fetchpriority_with_dependents( string $handle, array $checked = array(), array &$stored_results = array() ): ?string { 1080 if ( isset( $stored_results[ $handle ] ) ) { 1081 return $stored_results[ $handle ]; 1082 } 1083 1074 1084 // If there is a recursive dependency, return early. 1075 1085 if ( isset( $checked[ $handle ] ) ) { … … 1100 1110 if ( $highest_priority_index !== $high_priority_index ) { 1101 1111 foreach ( $this->get_dependents( $handle ) as $dependent_handle ) { 1102 $dependent_priority = $this->get_highest_fetchpriority_with_dependents( $dependent_handle, $checked );1112 $dependent_priority = $this->get_highest_fetchpriority_with_dependents( $dependent_handle, $checked, $stored_results ); 1103 1113 if ( is_string( $dependent_priority ) ) { 1104 1114 $highest_priority_index = max( … … 1112 1122 } 1113 1123 } 1114 1124 $stored_results[ $handle ] = $priorities[ $highest_priority_index ]; // @phpstan-ignore parameterByRef.type (We know the index is valid and that this will be a string.) 1115 1125 return $priorities[ $highest_priority_index ]; 1116 1126 }
Note: See TracChangeset
for help on using the changeset viewer.