From 61f5ccc6a391831ea886235d41c566c5fa73dc3b Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 3 Aug 2023 10:15:49 -0700 Subject: [PATCH] Ensure that no duplicate hooks can be provided. --- server-timing/load.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server-timing/load.php b/server-timing/load.php index 2b1f6b8f26..686f8c37b7 100644 --- a/server-timing/load.php +++ b/server-timing/load.php @@ -44,14 +44,17 @@ function perflab_sanitize_server_timing_setting( $value ) { return array(); } - // Ensure that every element is an indexed array of hook names. + /* + * Ensure that every element is an indexed array of hook names. + * Any duplicates across a group of hooks are removed. + */ return array_filter( array_map( static function( $hooks ) { if ( ! is_array( $hooks ) ) { $hooks = explode( "\n", $hooks ); } - return array_filter( array_map( 'sanitize_key', $hooks ) ); + return array_unique( array_filter( array_map( 'sanitize_key', $hooks ) ) ); }, $value )