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
Tutorial - Testing plugins for PHP Compatiblity #1562
Comments
Tutorial for review. Note to the reviewer, I again had some audio issues on this video, which I have noted and I will re-record those sections, but I wanted to get the video up for review so long. I'll make sure those audio glitches are fixed before publishing. php-compatibility.mp4 |
This content is ready to be reviewed. Please follow the steps listed under Guidelines for reviewing content. Thank you for your contribution! ✨ |
Great video as always @jonathanbossenger When you're running the composer commands, there are deprecation notices. Might be worth mentioning if people get these notices, they can ignore them? Otherwise, all good! |
Tutorial Review ChecklistPlease tick all items you've confirmed:
|
Hello @jonathanbossenger. This is a good video and I can hardly notice the audio glitches you made mention of. But can you kindly reword or fix some slight typo, punctuation, and sentence structure in the topic description please? |
Hi @WpNoisemaker thanks for the review. I agree with your suggestion to change "many plugins do still not support it fully" to "many plugins still do not support it fully" (I prefer to use "do not" instead of the contraction here, to make the point). However, the use of the word "to" in the last sentence is not supposed to be "you". |
Thanks for the review @digitalchild
Hmm interesting point, those notices are more related to my local PHP versions and would be different for different environments. That being said, it might be worth it in a future tutorial about composer, and to mention this. |
At the request of @jonathanbossenger, I'm leaving some feedback to the tutorial here. This feedback is not meant in any negative way. It is intended to help make the tutorial better. Note: I've not watched the video, I've only read the article and my remarks focus on the "Automated compatibility testing using PHPCompatibility" section of the article. Either way, here's some things I believe need fixing:
Other than that, but I know that's a biggie, I'm missing any mention of automated testing (vs manual testing) against all supported PHP versions using tooling like PHPUnit. The combination of automated tests + PHPCompatibility should be able to catch nearly everything. Manual testing is likely to miss a lot. Please let me know if you have questions about these points. |
Thank you for this feedback @jrfnl I am reopening this issue so that we can discuss the items you've detailed, and work towards improving the tutorial. I'll review your feedback this week, and get back to you with any questions I may have. |
@jrfnl before I reply to your specific points, I want to take the time to acknowledge the time taken to leave these notes and to thank you for your thorough review. I can't express how much I appreciate the technical feedback on my tutorials, especially given the fact that I know you do this voluntarily.
Good spot, thank you. I actually do mention this in the tutorial video, but not in the associated article. I will amend this.
You're not wrong, however, I'm struggling with two things here:
Perhaps I can convey this better, and change that sentence to this:
Would you feel comfortable with that rephrasing?
I was hoping that the sentence linking to the installation instructions on the PHP website would suffice, but perhaps it might be sufficient to leave a note like this:
Noted
Oh, wow. Today I learned about PHPCompatibilityWP! I had no idea this existed. I am probably going to need to update the rest of this tutorial to use this instead. Thank you for pointing this out. I'm also noting that any other changes related to PHPCompatibility vs. PHPCompatibilityWP will also need to be amended, so I will take them into account, but not refer to them further here.
It's been some time since my original research for this tutorial, but somewhere along the line, I got the impression this was required. This will probably change anyway now, given the above.
Noted, thank you.
You're 100% correct. In preparation for this tutorial, I went back to when I interviewed you for the WPTavern post I wrote about PHP 8 back in 2020, and made a note about automated testing. Then, when it came time to prepare the tutorial, I realized that automated testing is a whole other tutorial in itself and that I would need to first create that. I'm hoping to create a tutorial on automated testing in the near future, and once that's done come back to update this tutorial to include a section on automated testing, so that this tutorial is more rounded. For now, though, I hope that you'll agree with me that something on Learn WordPress about testing for compatibility is better than nothing at all. |
@jonathanbossenger Happy to help.
The thing is, all of this will also work in typical local development environments with the PHP binary included in that environment.
That definitely makes more sense to me.
You could maybe even use it to let people check if PHP is already installed as in that case it will already be in the path and they don't have to do a new install ;-)
Oops... well, glad I pointed that out in that case ;-) Note: WP Core itself is also using PHPCompatibilityWP. You can see a list of the framework/CMS specific rulesets available in the readme of PHPCompatibility. The packages all "live" in the same GH organisation too.
Note: PHPStan could probably help with finding that particular issue. Going into that is something for another tutorial, I suppose. Maybe mentioning that all tooling has limitations and that PHPStan compliments PHPCompatibility well for variable type related issues might still be valuable ?
Well, you could create anticipation for that future tutorial by a mention in this one ? Maybe something along the lines of the below ? |
That's a great idea, thanks
Thank you.
That is a great idea, I will do so. Thank you again @jrfnl for your valuable feedback. I'll be working on updating the article and re-recording the tutorial. I'll add this to my list for my batch of October tutorial work. I will post the updated article in Markdown format here once it's ready, and if you have time to review the updated version, that would be great, but I also appreciate that you have other, more important things to work on. |
@jrfnl as mentioned, I have completed the second draft of the tutorial, to include the changes we've discussed here. I know you are busy, but when/if you have some time, I would appreciate it if you could read through the new version, and let me know if you have any further feedback. With it being hosted on a public Github repo, if you'd prefer to simply suggest changes via a PR, I welcome that as well. Once again, I thank you greatly for your input, I really appreciate having such direct access to your vast knowledge of PHP compatibility testing, and I've enjoyed collaborating with you on this tutorial. |
WP 6.4 WordPress/gutenberg#52982 Bump plugin minimum supported PHP version to 7.0 https://make.wordpress.org/core/2023/08/10/whats-new-in-gutenberg-16-4-9-august/#minimum-supported-php-version-bumped-to-7-0 |
Hi @Greennc could I check, if was there a specific addition to the tutorial that you were suggesting to include, related to the minimum version? I do mention that currently WordPress requires PHP version 7.4. |
I presume you meant to say "recommends" ? |
Yeah, that's a good point. |
Thank you for all your work on this @jonathanbossenger ! I've gone through the new version. Please find my feedback/remarks below.
Only plugins or does the info in the tutorial also apply to themes containing PHP code ?
☝️ This is mostly a grammar thing, but it is also incorrect. A package can "reach end of life" or be "marked end of life by...". If the latter, it would be by the "developers of the PHP language" (which is written in C, so these are not necessarily PHP developers).
Suggestion: the current minimum PHP version to run WordPress is 7.0, with PHP 7.4 or higher being recommended.
WP is currently considered compatible (with select explicit exceptions) with PHP 8.0 and PHP 8.1.
Suggestion: "...lists the most important changes..." or just "...lists the changes..." (for all the changes, you'd need to go through the UPGRADING.md file of a release + the NEWS.md file and even those don't contain all the info).
May I recommend to run the code through WPCS and make sure that it complies with the WP Coding Standards ? (lead by example principle) It mostly does, but not completely by the looks of it.
It is actually
Eh... no, once this is done, you will have a
Please change the version constraint to
This is called using the "death-star", which is generally seen as a bad idea as it will allow for unmanaged upgrades to a new major release, which could, and more often than not does, break (CI) builds. Better to set this to
Suggestions: ... as when you'd run the tests... + ... the tests would fail, alerting you ...
Indeed and please know that I really appreciate you creating tutorials like this one and unlocking access to tooling like this to a wider group of developers, as it will ultimately benefit the end-users a great deal! |
Thank you so much @jrfnl for taking the time to review, I greatly appreciate your feedback.
Whoops! I think I might be spending too much time in |
I 100% agree with @jrfnl to change the wording of that sentence as it's misleading and incorrect. PHP 7.4 is not "required" for WordPress. Rather, the minimum PHP version WordPress supports is PHP 7.0. |
Something else to consider In lieu of rewriting around a premise of b/c, it might make sense to have an explicit call-out that you want to set PHPCompatibilityWP to the lowest supported version, but you should still run your env on the highest (or CI or whatever). |
Hello @jrfnl, after a short break (work trip and some leave) I have been able to implement your suggested changes, thank you. I will probably record the final tutorial video in the coming weeks, and work to have it updated on Learn WordPress before the end of the month. One question regarding the The main reason I ask is that whenever I prepare tutorials, I tend to refer to any specific documentation for installation instructions, and it would be ideal if the tutorial instructions matched the readme/documentation. Happy to create this PR if indeed this should be changed. |
@jonathanbossenger Hope you had a nice break! I look forward to seeing/reading the new version.
I'm inclined to say "no" as the installation instructions as per the README are the official ones for tagged releases and are correct for that. The "temporary" instructions are literally just that: temporary and should only be used while PHPCompatibility 10.0.0 has not been released yet. As soon as 10.0.0 comes out, people should revert back to using the official install instructions and not doing so will cause problems. In that respect, it might even be better to use the official instructions in the video (though a scan will then barely show anything PHP 8.x related) and to just mention that if someone wants to use "bleeding edge" PHPCompatibility , which includes a lot of checks related to PHP 8.x, that people can find instructions on how to do that in the pinned issue. |
(or was your question about the install instructions not about the use of PHPCompatibility 10 ?) |
Sorry if this wasn't clear. My question was specifically related to your suggestion when requiring/installing PHPCompatibilityWP:
So
instead of
In the readme in the PHPCompatibilityWP repo under Installation instructions it indicates the second option. |
Correct. The README in the PHPCompatibilityWP repo will be updated to say |
Ok, got it, thanks. In order to publish the tutorial before 3.0 is released, but to keep it as updated as possible, I will include the suggested installation instructions, and make a note that the current installation instructions will change when 3.0 is released. |
@jrfnl I have an alternative suggestion regarding installation instructions and versions. Ultimately my goal is to create content that is both technically correct, as well as "evergreen". However I appreciate this is often not possible, but I'd like to try and reduce too many future updates to this content in the near future. How does this sound as a compromise: Keep the installation instructions in the tutorial in line with the instructions in the readme
Then, include a note that it's generally considered a good idea to specify a specific version, to prevent unmanaged upgrades to a new major release, and to specify a version for PHPCompatibilityWP, using the current stable version
After that, update the section on PHPCompatibility and PHPCompatibilityWP versions, as follows (see next comment): |
A note on PHPCompatibility and PHPCompatibilityWP versions.Currently, the stable release of PHPCompatibility is 9.3.5, and the most recent sniffs are part of the upcoming version 10.0.0. release. The current stable version of PHPCompatibilityWP is 2.1.4 When version 10.0 of PHPCompatibility is released, version 3.0 of PHPCompatibilityWP will be released, which will depend on PHPCompatibility version 10.0. In the meantime, it is possible to install the dev-develop branch of PHPCompatibility to run PHPCS with the cutting-edge additions of PHP 8 sniffs before their release in version 10.0.0 of PHPCompatibility as detailed in this WordPress VIP documentation. To do this, run the following commands to alias the dev-develop branch of PHPCompatibility: composer config minimum-stability dev
composer require --dev phpcompatibility/phpcompatibility-wp:"^2.1"
composer require --dev phpcompatibility/php-compatibility:"dev-develop as 9.99.99" These commands will alias the Once PHPCompatibility 10 and PHPCompatibilityWP 3 are released, it should be possible to update the PHPCompatibilityWP version constraint to "^3.0", which will depend on version 10 of PHPCompatibility. |
The goal here is to allow for an easy update to both the text and the video once PHPCompatibility 10 and PHPCompatibilityWP are released, as I can just delete the section on PHPCompatibility and PHPCompatibilityWP versions, and update the installation instructions to match the updated instructions from the project readme. |
@jonathanbossenger I'm a layperson here (not even that compared to @jrfnl) , but I always understood this principle to be about avoiding using Meaning if you use |
@jrfnl is there any specific reason not to simply exclude the "*" as @justlevine has suggested? I try as much as possible to follow any software/dependancy-specific installation instructions in my tutorials, to avoid confusion from learning from the content ("why do you say do x when the docs say do y"). |
Hi @jrfnl I hope you don't mind the ping, I just wanted to check if you agree the above suggestion is a good way forward. |
The updated version of this has been published: https://learn.wordpress.org/tutorial/testing-your-products-for-php-version-compatibility/ Thanks to everyone for their input. Please feel free to reopen this issue if there are any other suggested changes. |
Topic Description
With all versions of PHP 7 now officially EOL (end of life) any plugins you develop, or have developed, must support PHP 8. While WordPress does run on PHP 8, many plugins still do not support it fully. In this workshop, we'll look at how to can test your plugins for PHP compatibility, in order to get them updated.
Related Resources
Links to related content on Learn, HelpHub, DevHub, GitHub Gutenberg Issues, DevNotes, etc.
Guidelines
Review the team guidelines
Tutorial Development Checklist
The text was updated successfully, but these errors were encountered: