Check for required PHP extensions upon plugin initialization #4930
Check for required PHP extensions upon plugin initialization #4930swissspidy merged 37 commits intomainfrom
Conversation
|
Size Change: 0 B Total Size: 1.4 MB ℹ️ View Unchanged
|
Codecov Report
@@ Coverage Diff @@
## main #4930 +/- ##
==========================================
- Coverage 76.15% 75.81% -0.34%
==========================================
Files 920 921 +1
Lines 16294 16381 +87
==========================================
+ Hits 12409 12420 +11
- Misses 3885 3961 +76
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
CC @westonruter and @schlessera as this PR may interest them. |
includes/namespace.php
Outdated
| add_action( 'admin_notices', __NAMESPACE__ . '\_print_missing_build_admin_notice' ); | ||
|
|
||
| if ( ( defined( 'WP_CLI' ) && WP_CLI ) || 'true' === getenv( 'CI' ) || 'cli' === PHP_SAPI ) { | ||
| // In CLI context, existence of the JS files is not required. |
There was a problem hiding this comment.
Let's ditch this.
While existence of the JS files is not required in CLI context, this should be surfaced to the user nonetheless, because it still means the plugin is incomplete and not working as expected.
That means we can use the same checks in CLI context and regular context.
That means we can just use one run_checks() method in both places.
There was a problem hiding this comment.
@swissspidy I remember why we did this in the first place. Without the javascript files the unit tests fail. Building javascript will take time and massively slow down the phpunit tests runs. I have a workaround here a43bae9
There was a problem hiding this comment.
Summary
Create a new
Compatibilityclass and move repeated logic like checks for PHP and WordPress versions to new class. Each method on the class implements a check and can be called from different contexts. The class has some new checks, mostly copied from the AMP plugin.Relevant Technical Choices
Implementing these checks as a class means if the plugin isn't built then the class file has to be loaded manually. There is no way around this but it does work pretty well in my testing.
Lots of the checks are set as class properties. There has two benefits.
Standard gettings and setters have been used to populate values into class properties. This makes the signature of the contractor a little cleaner.
This list of extensions, functions and classes was generated by doing a lot of research into the code. It is different from the amp list. Specially the json extension check.
To-do
User-facing changes
One implement, is that if multiple check fail, this will be displayed to the user, using bullet points. See this example.
Testing Instructions
Installed plugin on site that doesn't have stories min require, like PHP 5.5 or WordPress 5.2 and active plugin. See warning message.
Fixes #4791