Problem/Motivation

-----------------------------------------------------------------------------
Line token.tokens.inc
-----------------------------------------------------------------------------
1025 Call to deprecated method randomBytes() of class Drupal\Component\Utility\Crypt:
in Drupal 8.8.0 and will be removed before Drupal 9.0.0.
Use PHP's built-in random_bytes() function instead.
-----------------------------------------------------------------------------

Proposed resolution

Replace the current call with the suggested method.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#4 3071644-4.patch888 bytesidebr
#3 3071644-3.patch0 bytesidebr

Comments

idebr created an issue. See original summary.

idebr’s picture

Issue summary: View changes
idebr’s picture

Status: Active » Needs review
StatusFileSize
new0 bytes

Attached patch replaces the current call to \Drupal\Component\Utility\Crypt::randomBytes() with the suggested method random_bytes().

idebr’s picture

StatusFileSize
new888 bytes

Fixed empty patch file.

idebr’s picture

Status: Needs review » Postponed

Postponed until 8.8.x is the minimum supported version.

krzysztof domański’s picture

Deprecate \Drupal\Component\Utility\Crypt::randomBytes() in favour of PHP's builtin random_bytes() (3054311)

The random_bytes is a php function since PHP 7.0. However, drupal 8.7 still supports PHP 5.6.

/**
 * Generates cryptographically secure pseudo-random bytes
 * @link https://php.net/manual/en/function.random-bytes.php
 * @param int $length The length of the random string that should be returned in bytes.
 * @return string Returns a string containing the requested number of cryptographically secure random bytes.
 * @since 7.0
 * @throws Exception if it was not possible to gather sufficient entropy.
 */
function random_bytes ($length) {}
kristen pol’s picture

Issue tags: +Drupal 9 compatibility

Per a Slack discussion with Gábor Hojtsy regarding usage of D9 tags (Drupal 9, Drupal 9 compatibility, Drupal 9 readiness, etc.), "Drupal 9 compatibility" should be used for contributed projects that need updating and "Drupal 9" was the old tag for D8 issues before the D9 branch was ready. Doing tag cleanup here based on that discussion.

berdir’s picture

Status: Postponed » Closed (duplicate)