Skip to content

Integrate with Site Health#3886

Merged
westonruter merged 33 commits intodevelopfrom
add/2199-site-health
Dec 19, 2019
Merged

Integrate with Site Health#3886
westonruter merged 33 commits intodevelopfrom
add/2199-site-health

Conversation

@kienstra
Copy link
Copy Markdown
Contributor

@kienstra kienstra commented Dec 5, 2019

Summary

Integrates with Site Health in the 'Status' and 'Info' tabs.

Status tab

curl-multi

persistent-o-cache

icu-version

Info (debug) tab

debugging-info

Fixes #2199

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

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'.
@googlebot googlebot added the cla: yes Signed the Google CLA label Dec 5, 2019
@kienstra
Copy link
Copy Markdown
Contributor Author

kienstra commented Dec 5, 2019

I still need to consider #2199 (comment) and #2199 (comment).

Comment on lines +283 to +292
return array_merge(
$extensions,
[
'spl' => [
'extension' => 'spl',
'function' => 'spl_autoload_register',
'required' => true,
],
]
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since spl is required, the AMP plugin won't even initialize without it, right?

amp-wp/amp.php

Lines 72 to 74 in e6f9dc3

'spl' => array(
'functions' => array( 'spl_autoload_register' ),
),

So is spl relevant here? The test would never fail.

What is relevant are tests for the suggest packages:

amp-wp/composer.json

Lines 29 to 34 in e6f9dc3

"suggest": {
"ext-intl": "Enables use of idn_to_utf8() to convert punycode domains to UTF-8 for use with an AMP Cache.",
"ext-json": "Provides native implementation of json_encode()/json_decode().",
"ext-mbstring": "Used by PHP-CSS-Parser when working with stylesheets.",
"ext-zip": "Enables the use of ZipArchive to export AMP Stories."
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be unset in tearDown, yeah?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. 8d19165 does that.

],
'description' => esc_html__( 'The AMP plugin performs at its best when persistent object cache is enabled.', 'amp' ),
'actions' => '',
'test' => 'persistent_object_cache',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's prefix all tests with amp_

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, 60970ce does that.

'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' ),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing /* translators: ... */ comment in the preceding line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, 3e95814 adds the translators comment.

Comment on lines +187 to 196
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();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

@kienstra kienstra Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
*/
public function icu_version() {
$icu_version = defined( 'INTL_ICU_VERSION' ) ? (float) INTL_ICU_VERSION : null;
$minimum_version = 4.6;
Copy link
Copy Markdown
Contributor Author

@kienstra kienstra Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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():

$domain = idn_to_utf8( $domain, IDNA_DEFAULT, defined( 'INTL_IDNA_VARIANT_UTS46' ) ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003 );

...and that won't trigger the deprecation warning mentioned here.

Copy link
Copy Markdown
Contributor Author

@kienstra kienstra Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@kienstra kienstra changed the title [WIP] Integrate with Site Health Integrate with Site Health Dec 19, 2019

// 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(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kienstra
Copy link
Copy Markdown
Contributor Author

Ready For Another Round Of Review When Available

Hi @westonruter,
See you in a bit 😄

When you have a chance, this should be ready for another round of review.

@westonruter westonruter added this to the v1.5 milestone Dec 19, 2019
@westonruter westonruter merged commit 22056fb into develop Dec 19, 2019
@westonruter westonruter deleted the add/2199-site-health branch December 19, 2019 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Signed the Google CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate with Site Health Check

3 participants