File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7990,12 +7990,24 @@ function wp_raise_memory_limit( $context = 'admin' ) {
79907990 * Generates a random UUID (version 4).
79917991 *
79927992 * @since 4.7.0
7993- * @since 7.0.0 Uses wp_rand instead of mt_rand if available.
7993+ * @since 7.0.0 Uses wp_rand if available.
79947994 *
79957995 * @return string UUID.
79967996 */
79977997function wp_generate_uuid4 () {
7998- $ randomizer = function_exists ( 'wp_rand ' ) ? 'wp_rand ' : 'mt_rand ' ;
7998+ static $ backup_randomizer = false ;
7999+ $ randomizer = function_exists ( 'wp_rand ' ) ? 'wp_rand ' : $ backup_randomizer ;
8000+
8001+ if ( false === $ randomizer ) {
8002+ try {
8003+ random_int ( 0 , 15705 );
8004+ $ backup_randomizer = 'random_int ' ;
8005+ } catch ( Exception $ e ) {
8006+ $ backup_randomizer = 'mt_rand ' ;
8007+ }
8008+ $ randomizer = $ backup_randomizer ;
8009+ }
8010+
79998011 return sprintf (
80008012 '%04x%04x-%04x-%04x-%04x-%04x%04x%04x ' ,
80018013 $ randomizer ( 0 , 0xffff ),
You can’t perform that action at this time.
0 commit comments