[wp-trac] [WordPress Trac] #57137: Upgrade to 6.1.1: Error in pluggable.php (function wp_rand)

WordPress Trac noreply at wordpress.org
Thu Nov 17 19:27:44 UTC 2022


#57137: Upgrade to 6.1.1: Error in pluggable.php (function wp_rand)
-------------------------------+---------------------
 Reporter:  anniew86           |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  6.1.2
Component:  General            |     Version:  6.1.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+---------------------
Changes (by SergeyBiryukov):

 * keywords:   => reporter-feedback
 * milestone:  Awaiting Review => 6.1.2


Old description:

> After upgrade a simple test WP to 6.1.1 some posts are not displayed and
> following error occures in pluggable.php in the body of function wp_rand:
>
> Fatal error: Maximum execution time of 30 seconds exceeded in
> /var/www/html/wp/wp-includes/pluggable.php on line 2660
>
> The line number vary between 2660 and 2662.
>
> Here the relevant coding with line numbers:
>
> 2655 // Use PHP's CSPRNG, or a compatible method.
> 2656 static $use_random_int_functionality = true;
> 2657 if ( $use_random_int_functionality ) {
> 2658   try {
> 2659   // wp_rand() can accept arguments in either order, PHP cannot.
> 2660   $_max = max( $min, $max );
> 2661   $_min = min( $min, $max );
> 2662   $val  = random_int( $_min, $_max );
> 2663   if ( false !== $val ) {
>
> It doesn't help to increase the timeout.
>
> All plugins are deactivated, the standard WP theme is used, WP is used in
> the network mode.
>
> If the variable $use_random_int_functionality is set to false (line 2656)
> than the error doesn't occure but the post will not be rendered
> (inifitive processing)

New description:

 After upgrade a simple test WP to 6.1.1 some posts are not displayed and
 following error occures in pluggable.php in the body of function wp_rand:

 Fatal error: Maximum execution time of 30 seconds exceeded in
 /var/www/html/wp/wp-includes/pluggable.php on line 2660

 The line number vary between 2660 and 2662.

 Here the relevant coding with line numbers:
 {{{
 2655 // Use PHP's CSPRNG, or a compatible method.
 2656 static $use_random_int_functionality = true;
 2657 if ( $use_random_int_functionality ) {
 2658   try {
 2659   // wp_rand() can accept arguments in either order, PHP cannot.
 2660   $_max = max( $min, $max );
 2661   $_min = min( $min, $max );
 2662   $val  = random_int( $_min, $_max );
 2663   if ( false !== $val ) {
 }}}

 It doesn't help to increase the timeout.

 All plugins are deactivated, the standard WP theme is used, WP is used in
 the network mode.

 If the variable `$use_random_int_functionality` is set to false (line
 2656) than the error doesn't occure but the post will not be rendered
 (inifitive processing)

--

Comment:

 Hi there, welcome to WordPress Trac! Thanks for the report.

 The function was indeed updated for WP 6.1 in [53473] / #55194 to bring
 parity with the `random_int()` and `mt_rand()` native PHP functions when
 `$min` and `$max` values are both equal to `0`.

 At a glance, I don't see yet whether than change is related or not. Moving
 to 6.1.2 for investigation.

 * Could you check if the issue occurs in both WP 6.1 and 6.1.1, or just
 6.1.1?
 * What is the PHP version on the affected site?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57137#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list