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 8 fixes for wp_localize_script() #1022

Closed

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Feb 19, 2021

Trac ticket: https://core.trac.wordpress.org/ticket/52534
Replaces patch PR: #1007

Commit 1: WP_Scripts::localize: add tests with different data formats

These tests will pass on PHP < 8.
On PHP 8, only the Only the first byte will be assigned to the string offset warning for the string test should fail.

Commit 2: WP_Scripts::localize: fix PHP 8 issue and add _doing_it_wrong() for unsupported formats

This removes the "Only the first byte will be assigned to the string offset" warning on PHP 8.

This also adds a _doing_it_wrong() warning for all unsupported data formats.

Includes minor adjustments to the test to expect the _doing_it_wrong() warning.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

jrfnl and others added 2 commits February 19, 2021 10:31
These tests will pass on PHP < 8.
On PHP 8, only the `Only the first byte will be assigned to the string offset` warning for the `string` test should fail.

Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Sergey Biryukov <sergeybiryukov@git.wordpress.org>
…nsupported formats

This removes the "Only the first byte will be assigned to the string offset" warning on PHP 8.

This also adds a `_doing_it_wrong()` warning for all unsupported data formats.

Includes minor adjustments to the test to expect the `_doing_it_wrong()` warning.

Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Sergey Biryukov <sergeybiryukov@git.wordpress.org>
@jrfnl jrfnl changed the title WP_Scripts::localize: add tests with different data formats PHP 8 fixes for wp_localize_script() Feb 19, 2021
@hellofromtonya
Copy link
Contributor

Merged with changeset https://core.trac.wordpress.org/changeset/50408

@jrfnl jrfnl deleted the trac-5234/patch-without-bc-break branch February 23, 2021 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants