Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP is deprecating rand() functions in PHP 8.3 #2247

Open
chrisblakley opened this issue May 29, 2023 · 4 comments
Open

PHP is deprecating rand() functions in PHP 8.3 #2247

chrisblakley opened this issue May 29, 2023 · 4 comments
Labels
Backend (Server) Related to the server-side (includes PHP, HTML, etc).
Milestone

Comments

@chrisblakley
Copy link
Owner

chrisblakley commented May 29, 2023

Will need to find alternatives throughout Nebula and monitor vendor libraries for support as well.

https://wiki.php.net/rfc/deprecations_php_8_3#mt_rand_php

Screenshot 2023-05-29 at 7 53 07 PM

Seems like random_int() is the alternative now.

@chrisblakley chrisblakley added the Backend (Server) Related to the server-side (includes PHP, HTML, etc). label May 29, 2023
@chrisblakley chrisblakley added this to the 12.0 Flame milestone May 29, 2023
@chrisblakley
Copy link
Owner Author

Locations in Nebula itself where these appear:

  • Admin.php
  • Utilities.php
  • Analytics.php
  • Shortcodes.php
  • Functions.php
  • metadata.php

Also appears in scssphp (x5) and plugin-update-checker (x2). There is an update available to the latter, but I doubt it addresses this quite yet.

@chrisblakley
Copy link
Owner Author

chrisblakley commented May 30, 2023

Need to find an alternative to mt_getrandmax() as well which is used in metadata.php.

'?nocache' . mt_rand(1000, mt_getrandmax()) . '=debug' . mt_rand(1000, mt_getrandmax())

This is what I came up with:

'?nocache' . random_int(1000, PHP_INT_MAX) . '=debug' . random_int(1000, PHP_INT_MAX)

However, for this particular implementation I'll probably simplify to:

'?nocache' . random_int(100000, 999999) . '=debug' . random_int(100000, 999999)

@chrisblakley
Copy link
Owner Author

Nebula has been updated, but still needs scssphp and plugin-update-checker to be updated before this can be closed.

Note that random_int() requires the libsodium package in PHP, so make sure that is always installed on servers.

chrisblakley added a commit that referenced this issue Jun 6, 2023
…F7 blocks, rand deprecations, new woocommerce plugin

#2248 #2247 #2237
@chrisblakley chrisblakley modified the milestones: 12.0 Flame, 13.0 Bubble May 1, 2024
@chrisblakley
Copy link
Owner Author

Here is what vendor libraries are using:

  • mt_getrandmax() in scssphp in Compiler.php
  • mt_rand() in scssphp in Compiler.php several times
  • mt_rand() in PUC in OAuthSinature.php several times

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend (Server) Related to the server-side (includes PHP, HTML, etc).
Projects
None yet
Development

No branches or pull requests

1 participant