Skip to content

PHP 8.2 | Fix deprecated embedded variables in text strings - #44538

Merged
anton-vlasenko merged 1 commit into
trunkfrom
php-8.2/fix-deprecated-embedded-variables
Oct 3, 2022
Merged

anton-vlasenko merged 1 commit into
trunkfrom
php-8.2/fix-deprecated-embedded-variables

Conversation

@jrfnl

@jrfnl jrfnl commented Sep 28, 2022 •

Copy link
Copy Markdown
Member

What?

PHP 8.2 will deprecate two of the four currently supported syntaxes for embedding variables in double quoted text string/heredocs.

This library contains six uses of embedded variables using braces after the dollar sign ("${foo}"), which is one of the deprecated forms.

This commit fixes all six.

Refs:

Why?

Because code should be cross-version compatible with all supported PHP versions, including the upcoming PHP 8.2.

PHP 8.2 will deprecate two of the four currently supported syntaxes for embedding variables in double quoted text string/heredocs.

This library contains six uses of embedded variables using braces after the dollar sign (`"${foo}"`), which is one of the deprecated forms.

This commit fixes all six.

Refs:
* https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
@jrfnl
jrfnl requested a review from spacedmonkey as a code owner September 28, 2022 17:53
@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 28, 2022
@jrfnl jrfnl removed the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 28, 2022
@WordPress WordPress deleted a comment from github-actions Bot Sep 28, 2022
@gziolo

gziolo commented Sep 28, 2022

Copy link
Copy Markdown
Member

This library contains six uses of embedded variables using braces after the dollar sign ("${foo}"), which is one of the deprecated forms.

It’s a JavaScript syntax for variables in strings. 😃 Thank you for spotting and correcting it 👍

@anton-vlasenko anton-vlasenko added the [Type] Code Quality Issues or PRs that relate to code quality label Oct 3, 2022
@anton-vlasenko anton-vlasenko added this to the Gutenberg 14.3 milestone Oct 3, 2022

@anton-vlasenko anton-vlasenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!
Nice job.

@anton-vlasenko
anton-vlasenko merged commit 9c7c637 into trunk Oct 3, 2022
@anton-vlasenko
anton-vlasenko deleted the php-8.2/fix-deprecated-embedded-variables branch October 3, 2022 14:09
@jrfnl

jrfnl commented Oct 3, 2022

Copy link
Copy Markdown
Member Author

Does this need a port to WP Core ? Will this be handled automatically or should I open a PR to Core for this too ?

@anton-vlasenko

anton-vlasenko commented Oct 3, 2022 •

Copy link
Copy Markdown
Contributor

I wonder if this particular PR needs porting, as Core version of the WP_Theme_JSON class uses sprintf() for concatenation and probably(?) doesn't need this fix.
In general, a Backport to WP Beta/RC or a Backport to WP minor release label should be added to PRs that need backporting.

Will this be handled automatically or should I open a PR to Core for this too ?

As far as I know, this is handled by the release managers.
Here is the tracking issue for all Gutenberg PRs that need backporting:
#43440

@jrfnl jrfnl added Backport to WP Beta/RC Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release Needs PHP backport Needs PHP backport to Core labels Oct 3, 2022
@jrfnl

jrfnl commented Oct 3, 2022

Copy link
Copy Markdown
Member Author

@anton-vlasenko I have added the labels, let's see what happens...

@michalczaplinski michalczaplinski removed Backport to WP Beta/RC Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release labels Oct 3, 2022
@michalczaplinski

Copy link
Copy Markdown
Contributor

Hey 👋 I've removed the labels as this PR will not need to be ported to Core. The equivalent function in Core is already using the sprintf() syntax.

I wonder if in fact the GB should have the same syntax here as the Core one 🤔 .

@jrfnl

jrfnl commented Oct 3, 2022 •

Copy link
Copy Markdown
Member Author

Thanks @michalczaplinski for investigating.

I wonder if in fact the GB should have the same syntax here as the Core one

I imagine that would greatly improve the code readability as it reduces the length of that really long long line and makes it clear which are the variable parts.

@ramonjd ramonjd removed the Needs PHP backport Needs PHP backport to Core label Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants