Skip to content

[8.x] Fix deprecation issue with translator#42216

Merged
taylorotwell merged 1 commit into
8.xfrom
fix-translator-deprecation-2
May 2, 2022
Merged

[8.x] Fix deprecation issue with translator#42216
taylorotwell merged 1 commit into
8.xfrom
fix-translator-deprecation-2

Conversation

@driesvints

Copy link
Copy Markdown
Member

This fixes an issue where a translation param was null and triggers a deprecation warning in PHP 8.1. On lower PHP versions, the parameter is simple added as an empty string.

See #42204

@driesvints driesvints changed the title Fix deprecation issue with translator [8.x] Fix deprecation issue with translator May 2, 2022
foreach ($replace as $key => $value) {
$shouldReplace[':'.Str::ucfirst($key)] = Str::ucfirst($value);
$shouldReplace[':'.Str::upper($key)] = Str::upper($value);
$shouldReplace[':'.Str::ucfirst($key ?? '')] = Str::ucfirst($value ?? '');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think keys can ever be null?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only fixed the behavior that was previously in place. In any PHP version before 8.1, if null was used as a replacement it'd be casted to a string. Since PHP 8.1 throws a deprecation for this, we'll need to make sure to do this ourselves.

We can't change the behavior of handling null on 8.x or 9.x as that'd be a breaking change.

@taylorotwell taylorotwell merged commit f6e9f54 into 8.x May 2, 2022
@taylorotwell taylorotwell deleted the fix-translator-deprecation-2 branch May 2, 2022 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants