Conversation
Adds tests for persistent object cache and curl_multi_* functions.
Including the mode and the templates used. Also, add 'pcl' to the required extensions via a filter.
In the debugging section, add the content types, like 'post' and 'page'.
|
I still need to consider #2199 (comment) and #2199 (comment). |
| return array_merge( | ||
| $extensions, | ||
| [ | ||
| 'spl' => [ | ||
| 'extension' => 'spl', | ||
| 'function' => 'spl_autoload_register', | ||
| 'required' => true, | ||
| ], | ||
| ] | ||
| ); |
There was a problem hiding this comment.
Thanks, that's a good point. Tomorrow might be the earliest I could make that change, if that's alright.
This seems to be left over from something earlier.
As Weston pointed out, if the spl extension isn't present, the plugin won't even load. So check for the modules in the suggest value of composer.json: https://github.com/ampproject/amp-wp/blob/e6f9dc3587954e40c0c21bc66ccfa88f99aaa1b3/composer.json#L29-L34
Remove post type support for all posts that aren't in the dataProvider.
Simply add the post types to an array, instead of repeating the function.
It shouldn't be necessary to escape simple strings, also update DocBlocks.
It might instead check for an error on running idn_to_utf8(), like: Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in /home/tipsonlifeandlov/public_html/wp-content/plugins/amp/includes/class-amp-http.php on line 208
| $this->instance->persistent_object_cache() | ||
| ); | ||
|
|
||
| $GLOBALS['_wp_using_ext_object_cache'] = true; |
There was a problem hiding this comment.
This should be unset in tearDown, yeah?
src/Admin/SiteHealth.php
Outdated
| ], | ||
| 'description' => esc_html__( 'The AMP plugin performs at its best when persistent object cache is enabled.', 'amp' ), | ||
| 'actions' => '', | ||
| 'test' => 'persistent_object_cache', |
There was a problem hiding this comment.
Let's prefix all tests with amp_
src/Admin/SiteHealth.php
Outdated
| 'color' => $is_proper_version ? 'green' : 'orange', | ||
| ], | ||
| 'description' => sprintf( | ||
| esc_html__( 'The version of ICU can affect how the intl extension runs. The minimum recommended version of ICU is %s.', 'amp' ), |
There was a problem hiding this comment.
Missing /* translators: ... */ comment in the preceding line.
There was a problem hiding this comment.
Good point, 3e95814 adds the translators comment.
| function amp_bootstrap_admin() { | ||
| $admin_pointers = new AMP_Admin_Pointers(); | ||
| $admin_pointers->init(); | ||
|
|
||
| $post_meta_box = new AMP_Post_Meta_Box(); | ||
| $post_meta_box->init(); | ||
|
|
||
| $site_health = new SiteHealth(); | ||
| $site_health->init(); | ||
| } |
There was a problem hiding this comment.
General note: it seems somewhat strange that these instances are completely inaccessible since the variables are scoped in the function. This is probably a wider issue that should be addressed later, as it's worse to pollute the global namespace with more variables. /cc @schlessera
There was a problem hiding this comment.
Yeah, that's a good point. It'd be good to have some access to them.
This led to a failed Travis build, from a PHPCS error.
Thanks to Weston's suggesiton, this should help prevent conflicts with other plugins' tests.
As Weston brought up, there's a need to unset this.
Thanks to Brandon Kraft's comment, it looks like this version has teh INTL_IDNA_VARIANTE_UTS46 constant: #1439 (comment) And as long as that constant is defined, it will be passed to idn_to_utf8(): https://github.com/ampproject/amp-wp/blob/39336b78be7a4ba8b3a09a6f43d9f66e3c201e05/includes/class-amp-http.php#L233 ...and that won't trigger this deprecation warning: https://github.com/php/php-src/pull/2355/files#diff-24931a05f9e656989a55c44cf8a72f9eR294
src/Admin/SiteHealth.php
Outdated
| */ | ||
| public function icu_version() { | ||
| $icu_version = defined( 'INTL_ICU_VERSION' ) ? (float) INTL_ICU_VERSION : null; | ||
| $minimum_version = 4.6; |
There was a problem hiding this comment.
Thanks to Brandon Kraft's comment, it looks like ICU version 4.6 introduced the INTL_IDNA_VARIANTE_UTS46 constant.
And as long as that constant is defined, it will be passed to idn_to_utf8():
amp-wp/includes/class-amp-http.php
Line 233 in 39336b7
...and that won't trigger the deprecation warning mentioned here.
There was a problem hiding this comment.
Also, I tested this locally with PHP 7.2:
$ wp shell
$ wp> idn_to_utf8( 'foobar', IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46 );
=> string(6) "foobar" # As expected, no deprecation warning
$ wp> idn_to_utf8( 'foobar', IDNA_DEFAULT, INTL_IDNA_VARIANT_2003 );
PHP Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in phar:///usr/local/bin/wp/vendor/wp-cli/shell-command/src/WP_CLI/Shell/REPL.php(46) : eval()'d code on line 1
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/wp:0
....There was a problem hiding this comment.
So I think the minimum ICU version of 4.6 should be good.
If this is in Reader mode, it doesn't apply, so explain that.
Similar to how the other tests here work, so users can always find out more about it, with the link.
This is how the rest of the sprintf() calls in this PR are when they only have one interoplated string.
There is probably a more complex way to make this work, but %s seems simpler.
This is in the new src/ directory, under a namespace.
As Alain mentioned, it's easy to later change from final to non-final.
It looks like this needs to have a language in it, so pass it to a translation function.
I should have updated this earlier for the new URL for the curl documentation.
|
|
||
| // Add the supported templates, like 'is_author', if not in 'Reader' mode. | ||
| if ( AMP_Theme_Support::READER_MODE_SLUG !== AMP_Theme_Support::get_support_mode() ) { | ||
| $supported_templates = array_merge( |
There was a problem hiding this comment.
These are not translated, as this is debugging information that we might get on a WordPress.org support topic. It could be confusing to see these in different languages.
|
Ready For Another Round Of Review When Available Hi @westonruter, When you have a chance, this should be ready for another round of review. |
In deference to other plugins, as there are other AMP plugins.
Summary
Integrates with Site Health in the 'Status' and 'Info' tabs.
Status tab
Info (debug) tab
Fixes #2199
Checklist