Repository navigation
Upgrade: Use a nowdoc for the About WordPress redirect script - #16310
shail-mehta wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The change can block upgrades with an undefined-function fatal error on legacy WordPress versions and a parse error on PHP 7.0–7.2 before compatibility checks run.
2 open issues
What changed in this PR
This PR replaces the raw redirect script in the legacy About WordPress upgrade callback with WordPress’s inline-script helper.
Changes:
- Passes the static JavaScript through
wp_print_inline_script_tag()using a nowdoc. - Preserves the redirect destination,
about.php?updated.
| File | Description |
|---|---|
src/wp-admin/includes/update-core.php |
Changes script output in _redirect_to_about_wordpress() to use the helper and nowdoc. |
Review effort: Balanced
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Use an unindented nowdoc terminator so the file parses on PHP 7.0-7.2, and only call wp_print_inline_script_tag() when it exists, falling back to the raw script tag during upgrades from older WordPress versions. Props copilot-pull-request-reviewer. See #66856.
There was a problem hiding this comment.
🟡 Changes recommended
The added nowdoc syntax causes a parse error on PHP 5.2 before the upgrader can run its compatibility check, preventing the normal compatibility error from being returned.
1 open issue
2 resolved since last review
Review effort: Balanced
| <script> | ||
|
|
||
| // The closing JS; marker must not be indented (PHP < 7.3 compatibility). | ||
| $redirect_script = <<<'JS' |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
| // The closing JS; marker must not be indented (PHP < 7.3 compatibility). | ||
| $redirect_script = <<<'JS' | ||
| window.location = 'about.php?updated'; | ||
| </script> | ||
| <?php | ||
| JS; | ||
|
|
||
| // wp_print_inline_script_tag() is not available when upgrading from WordPress versions older than 5.7. | ||
| if ( function_exists( 'wp_print_inline_script_tag' ) ) { | ||
| wp_print_inline_script_tag( $redirect_script ); | ||
| } else { | ||
| echo "<script>\n{$redirect_script}\n</script>\n"; | ||
| } |
There was a problem hiding this comment.
This branch can never run. _redirect_to_about_wordpress() returns early unless the global $wp_version, the version being upgraded from, is older than 3.4-RC1 (line 2026), and wp_print_inline_script_tag() was added in 5.7. So the fallback always prints the same raw <script> as trunk. I'd keep trunk's tag with a comment explaining why it stays raw:
| // The closing JS; marker must not be indented (PHP < 7.3 compatibility). | |
| $redirect_script = <<<'JS' | |
| window.location = 'about.php?updated'; | |
| </script> | |
| <?php | |
| JS; | |
| // wp_print_inline_script_tag() is not available when upgrading from WordPress versions older than 5.7. | |
| if ( function_exists( 'wp_print_inline_script_tag' ) ) { | |
| wp_print_inline_script_tag( $redirect_script ); | |
| } else { | |
| echo "<script>\n{$redirect_script}\n</script>\n"; | |
| } | |
| // This only runs when upgrading from WordPress < 3.4, which predates wp_print_inline_script_tag() (5.7). | |
| ?> | |
| <script> | |
| window.location = 'about.php?updated'; | |
| </script> | |
| <?php |

What
Trac Ticket: #66856
Print the redirect script in
_redirect_to_about_wordpress()throughwp_print_inline_script_tag()and a NOWDOC wrapper.Why
This is the remaining raw script-tag block listed for
update-core.php.How
The script is static, so it is a plain nowdoc with no
wp_json_encode()arguments.Testing Instructions
Use of AI tools: