Opened 4 years ago
Last modified 4 years ago
#50787 accepted task (blessed)
Consolidate the logic for displaying WP & PHP compatibility messages for themes
Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Site Health | Keywords: | needs-testing needs-patch |
Focuses: | administration | Cc: |
Description (last modified by )
Background: #48491
As part of the changes on [48636-48638,48640], these messages are duplicated in at least seven different places:
- "This theme doesn’t work with your versions of WordPress and PHP. Please update WordPress, and then learn more about updating PHP."
- "This theme doesn’t work with your version of WordPress. Please update WordPress."
- "This theme doesn’t work with your version of PHP. Learn more about updating PHP."
See comment:36:ticket:48491 for the list of relevant areas.
It would be nice to consolidate the logic in one place.
Attachments (6)
Change History (30)
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 years ago
#6
@
4 years ago
- Keywords has-patch dev-feedback needs-testing added; needs-patch removed
50787.diff is an initial pass at this ticket.
This ticket was mentioned in Slack in #core by afragen. View the logs.
4 years ago
#8
@
4 years ago
A couple of code review notes:
Function naming
For the new function name, it's not clear to me what the function will do when invoked. I can infer. But I'm wondering if it would be more clear if action-based such as
wp_get_compatibility_string
to tell us that it "gets" and returns a single string. What do you think @afragen ?
Performance
Each time the function is called, the $strings
array rebuilds. This means each __()
has to run again, ie there are 12 of them. Is this necessary? Do we need to retranslate and rebuild the array each time the function is invoked?
We can use memoization for a tiny peformance boost.
#9
@
4 years ago
Revising my performance note above. See slack conversation.
The last 3 string elements are dynamic, i.e. build from the injected $name
. if no name is passed to the function, then we can skip building those last 3 elements.
For the non-dynamic strings, we can leverage memoization to generate the $strings
array once and then reuse the same array each time the function is invoked.
It's a tiny tiny performance boost.
#10
@
4 years ago
@SergeyBiryukov Can you please do a final review on the latest patch Andy and I did? What do you think?
This ticket was mentioned in PR #607 on WordPress/wordpress-develop by hellofromtonya.
4 years ago
#12
- Keywords has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/50787
Props: @afragen
#13
@
4 years ago
- Type changed from enhancement to task (blessed)
Thanks for the patch!
Didn't get a chance to review this in time for 5.6 Beta 1, but I think it can still go in before RC, since it's more of a cleanup than new functionality. Converting to a task for now.
This ticket was mentioned in Slack in #core-site-health by clorith. View the logs.
4 years ago
#15
@
4 years ago
- Milestone changed from 5.6 to 5.7
Didn't get a chance to review this in time for 5.6 RC, moving to the next release for now.
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 years ago
#18
@
4 years ago
For manually testing this patch:
- Get a plugin or theme that is not compatible with the WP version running in your local env
- Check that incompatible message appears
For example, plugin incompatible message:
This plugin doesn't work with your versions of WordPress and PHP.
This ticket was mentioned in Slack in #core by francina. View the logs.
4 years ago
#20
follow-up:
↓ 22
@
4 years ago
Thanks for the patch!
Just noting that 50787.2.diff is a good start, as it touches all the relevant areas, but is not quite what I envisioned for this ticket.
I would like to consolidate not just the strings (that doesn't seem to reduce much code), but also the repeated logic for these messages, i.e. various conditionals for adjusting them based on user capabilities and what actually needs updating. Sorry if that was not clear from the description.
#21
@
4 years ago
PHP Incompatibility Testing Strategy
How to test the PR
Pull the PR down to your local machine
git fetch origin pull/607/head:pr607 git checkout pr607
Step 2: Change the LOCAL_PHP=5.6-fpm
in .env
.
Step 3: Reprovision
Step 4: Log into the admin area as an admin
Testing the plugin's PHP incompatibility message:
We'll attempt to add a plugin that requires PHP 7+ while your local dev environment is running PHP 5.6.
Step 5: Go to the "Plugins" and then "Add Plugins" screen
Step 6: Type "WooCommerce" in the search plugins field. Press enter/return.
The incompatibility notice should appear across the top of the plugin:
This plugin doesn’t work with your version of PHP. Learn more about updating PHP.
Testing the theme's PHP incompatibility message:
Let's repeat this test with a theme that requires at least PHP 7.
Step 7: Go to the "Themes" and then "Add Theme" screen
Step 8: Type "Charitas Lite" in the search themes field. Press enter/return.
The incompatibility notice should appear across the top of the plugin:
This theme doesn’t work with your version of PHP. Learn more about updating PHP.
#22
in reply to:
↑ 20
@
4 years ago
- Keywords needs-patch added; has-patch has-unit-tests removed
Removing has-patch
and has-unit-tests
and adding needs-patch
to continue iterating on the solution per Sergey's review.
Replying to SergeyBiryukov:
Thanks for the patch!
Just noting that 50787.2.diff is a good start, as it touches all the relevant areas, but is not quite what I envisioned for this ticket.
I would like to consolidate not just the strings (that doesn't seem to reduce much code), but also the repeated logic for these messages, i.e. various conditionals for adjusting them based on user capabilities and what actually needs updating. Sorry if that was not clear from the description.
This ticket was mentioned in Slack in #core by paaljoachim. View the logs.
4 years ago
#24
@
4 years ago
- Milestone changed from 5.7 to Future Release
With 5.7 RC1 landing tomorrow and no activity on this ticket for a new patch, punting this ticket to Future Release
.
If any maintainer or committer feels this can be resolved in time, or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.
Per Sergey during today's scrub: