diff --git a/.github/workflows/tests-unit-php.yml b/.github/workflows/tests-unit-php.yml index 829ddd861bf1..8e29ce9f6291 100644 --- a/.github/workflows/tests-unit-php.yml +++ b/.github/workflows/tests-unit-php.yml @@ -55,7 +55,7 @@ jobs: php: ['7.0', '8.0'] # Using a branch instead instead of 'latest' or a specific version ensures we - # get the latest test utils from that branch that includes the PHPUnity polyfills. + # get the latest test utils from that branch that includes the PHPUnit polyfills. # TODO: Switch to 'latest' once a new minor release is out. wp: ['5.8'] coverage: [false] @@ -77,10 +77,9 @@ jobs: wp: 'trunk' experimental: true - # TODO(#8520): Enable 8.1 tests once compat improves. - # - php: '8.1' - # wp: 'trunk' - # experimental: true + - php: '8.1' + wp: 'trunk' + experimental: true steps: - name: Checkout diff --git a/composer.json b/composer.json index 1046edce1dac..07a8ea545580 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", - "ampproject/amp-toolbox": "0.6.0", - "ampproject/amp-wp": "2.1.4", + "ampproject/amp-toolbox": "*", + "ampproject/amp-wp": "dev-develop", "civicrm/composer-downloads-plugin": "^3.0", "cweagans/composer-patches": "^1.6", "enshrined/svg-sanitize": "^0.14.0", diff --git a/composer.lock b/composer.lock index fbd2bcbed27f..103da29d76e6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "480ddcc2bce3b5e794ae3fcbd83bc03a", + "content-hash": "0522f2700e9d46950513f24d493e33e2", "packages": [ { "name": "ampproject/amp-toolbox", - "version": "v0.6.0", + "version": "0.8.2", "source": { "type": "git", "url": "https://github.com/ampproject/amp-toolbox-php.git", - "reference": "500012f27cc27f4d72525cf0f010602fb95e2f6f" + "reference": "fe72826d28724385de5f6a76256a1e6299ece95c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/500012f27cc27f4d72525cf0f010602fb95e2f6f", - "reference": "500012f27cc27f4d72525cf0f010602fb95e2f6f", + "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/fe72826d28724385de5f6a76256a1e6299ece95c", + "reference": "fe72826d28724385de5f6a76256a1e6299ece95c", "shasum": "" }, "require": { @@ -36,7 +36,7 @@ "phpcompatibility/php-compatibility": "^9", "phpunit/phpunit": "^5 || ^6 || ^7 || ^8 || ^9", "roave/security-advisories": "dev-master", - "sirbrillig/phpcs-variable-analysis": "2.11.1", + "sirbrillig/phpcs-variable-analysis": "2.11.2", "squizlabs/php_codesniffer": "^3", "wp-coding-standards/wpcs": "^2.3", "yoast/phpunit-polyfills": "^0.2.0 || ^1.0.0" @@ -44,6 +44,7 @@ "suggest": { "ext-json": "Provides native implementation of json_encode()/json_decode().", "ext-mbstring": "Used by Dom\\Document to convert encoding to UTF-8 if needed.", + "mck89/peast": "Needed to minify the AMP script.", "nette/php-generator": "Needed to generate the validator spec PHP classes and interfaces." }, "bin": [ @@ -71,26 +72,26 @@ "description": "A collection of AMP tools making it easier to publish and host AMP pages with PHP.", "support": { "issues": "https://github.com/ampproject/amp-toolbox-php/issues", - "source": "https://github.com/ampproject/amp-toolbox-php/tree/v0.6.0" + "source": "https://github.com/ampproject/amp-toolbox-php/tree/0.8.2" }, - "time": "2021-06-30T15:16:48+00:00" + "time": "2021-10-27T12:32:13+00:00" }, { "name": "ampproject/amp-wp", - "version": "2.1.4", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/ampproject/amp-wp", - "reference": "5f577ecf4a7cae594fa0931d78fbc2b045ad5053" + "reference": "5405daa38e65f0ec16ffc920014d0110b03ee773" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ampproject/amp-wp/zipball/5f577ecf4a7cae594fa0931d78fbc2b045ad5053", - "reference": "5f577ecf4a7cae594fa0931d78fbc2b045ad5053", + "url": "https://api.github.com/repos/ampproject/amp-wp/zipball/5405daa38e65f0ec16ffc920014d0110b03ee773", + "reference": "5405daa38e65f0ec16ffc920014d0110b03ee773", "shasum": "" }, "require": { - "ampproject/amp-toolbox": "0.6.0", + "ampproject/amp-toolbox": "0.8.2", "cweagans/composer-patches": "~1.0", "ext-curl": "*", "ext-date": "*", @@ -110,13 +111,13 @@ "civicrm/composer-downloads-plugin": "^3.0", "dealerdirect/phpcodesniffer-composer-installer": "0.7.1", "google/cloud-storage": "^1.22", - "mikey179/vfsstream": "1.6.8", + "mikey179/vfsstream": "1.6.9", "mustache/mustache": "^2", "php-stubs/wordpress-stubs": "^5.3.2", "phpcompatibility/phpcompatibility-wp": "2.1.1", "phpdocumentor/reflection": "~3.0", "roave/security-advisories": "dev-latest", - "sirbrillig/phpcs-variable-analysis": "2.11.0", + "sirbrillig/phpcs-variable-analysis": "2.11.2", "wp-cli/export-command": "^2.0", "wp-cli/extension-command": "^2.0", "wp-cli/wp-cli": "^2.4", @@ -128,6 +129,7 @@ "ext-intl": "Enables use of idn_to_utf8() to convert punycode domains to UTF-8 for use with an AMP Cache.", "ext-mbstring": "Used by PHP-CSS-Parser when working with stylesheets." }, + "default-branch": true, "type": "wordpress-plugin", "extra": { "downloads": { @@ -188,7 +190,7 @@ ], "description": "WordPress plugin for adding AMP support.", "homepage": "https://github.com/ampproject/amp-wp", - "time": "2021-08-31T16:24:05+00:00" + "time": "2021-11-23T02:01:38+00:00" }, { "name": "civicrm/composer-downloads-plugin", @@ -4225,6 +4227,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { + "ampproject/amp-wp": 20, "sabberworm/php-css-parser": 20, "roave/security-advisories": 20 }, diff --git a/includes/AMP/Optimization.php b/includes/AMP/Optimization.php index b600bd37f290..f91faa53f14b 100644 --- a/includes/AMP/Optimization.php +++ b/includes/AMP/Optimization.php @@ -118,7 +118,7 @@ private function get_optimizer() { * @since 1.1.0 * * @see AmpWPConfiguration::apply_filters() - * @link https://github.com/ampproject/amp-wp/blob/51266bf237184eae06e0d972cf423fa7bef61648/src/Optimizer/AmpWPConfiguration.php#L33-L99 + * @link https://github.com/ampproject/amp-wp/blob/5405daa38e65f0ec16ffc920014d0110b03ee773/src/Optimizer/AmpWPConfiguration.php#L43-L78 * * @return Configuration Optimizer configuration to use. */ diff --git a/patches/amp-wp-allow-amp-story-captions.patch b/patches/amp-wp-allow-amp-story-captions.patch deleted file mode 100644 index 0488300709ec..000000000000 --- a/patches/amp-wp-allow-amp-story-captions.patch +++ /dev/null @@ -1,471 +0,0 @@ -diff --git includes/sanitizers/class-amp-allowed-tags-generated.php includes/sanitizers/class-amp-allowed-tags-generated.php -index 831a10439..ed2bc842b 100644 ---- includes/sanitizers/class-amp-allowed-tags-generated.php -+++ includes/sanitizers/class-amp-allowed-tags-generated.php -@@ -264,6 +264,7 @@ class AMP_Allowed_Tags_Generated { - 'amp-state', - 'amp-story-360', - 'amp-story-auto-analytics', -+ 'amp-story-captions', - 'amp-story-interactive-binary-poll', - 'amp-story-interactive-img-poll', - 'amp-story-interactive-img-quiz', -@@ -6253,6 +6254,39 @@ class AMP_Allowed_Tags_Generated { - ), - ), - ), -+ 'amp-story-captions' => array( -+ array( -+ 'attr_spec_list' => array( -+ 'media' => array(), -+ 'noloading' => array( -+ 'value' => array( -+ '', -+ ), -+ ), -+ ), -+ 'tag_spec' => array( -+ 'amp_layout' => array( -+ 'supported_layouts' => array( -+ 6, -+ 2, -+ 3, -+ 7, -+ 8, -+ 9, -+ 4, -+ ), -+ ), -+ 'child_tags' => array( -+ 'mandatory_num_child_tags' => 0, -+ ), -+ 'mandatory_ancestor' => 'amp-story', -+ 'requires_extension' => array( -+ 'amp-story-captions', -+ ), -+ 'spec_url' => 'https://amp.dev/documentation/components/amp-story-captions', -+ ), -+ ), -+ ), - 'amp-story-consent' => array( - array( - 'attr_spec_list' => array( -@@ -7564,6 +7598,11 @@ class AMP_Allowed_Tags_Generated { - 'google', - ), - ), -+ 'captions-id' => array( -+ 'requires_extension' => array( -+ 'amp-story-captions', -+ ), -+ ), - 'controls' => array( - 'value' => array( - '', -@@ -13526,11 +13565,15 @@ class AMP_Allowed_Tags_Generated { - array( - 'attr_spec_list' => array(), - 'tag_spec' => array( -- 'mandatory' => true, -+ 'child_tags' => array( -+ 'child_tag_name_oneof' => array( -+ 'style', -+ ), -+ 'mandatory_min_num_child_tags' => 1, -+ ), - 'mandatory_parent' => 'head', -- 'spec_name' => 'noscript enclosure for boilerplate', -+ 'spec_name' => 'noscript enclosure for amp style tags', - 'spec_url' => 'https://amp.dev/documentation/guides-and-tutorials/learn/spec/amp-boilerplate/?format=websites', -- 'unique' => true, - ), - ), - array( -@@ -14287,7 +14330,6 @@ class AMP_Allowed_Tags_Generated { - ), - ), - 'tag_spec' => array( -- 'mandatory_alternatives' => 'amphtml engine script', - 'mandatory_parent' => 'head', - 'spec_name' => 'amphtml engine script', - 'spec_url' => 'https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml/#required-markup', -@@ -14330,7 +14372,6 @@ class AMP_Allowed_Tags_Generated { - ), - ), - 'tag_spec' => array( -- 'mandatory_alternatives' => 'amphtml engine script', - 'mandatory_parent' => 'head', - 'spec_name' => 'amphtml engine script (LTS)', - 'spec_url' => 'https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml/#required-markup', -@@ -15249,6 +15290,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-accordion', - 'requires_usage' => true, -@@ -15657,6 +15701,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-base-carousel', - 'requires_usage' => true, -@@ -15817,6 +15864,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-brightcove', - 'requires_usage' => true, -@@ -16068,9 +16118,12 @@ class AMP_Allowed_Tags_Generated { - 'tag_spec' => array( - 'extension_spec' => array( - 'bento' => array( -- 'has_css' => false, -+ 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-date-countdown', - 'requires_usage' => true, -@@ -16104,9 +16157,12 @@ class AMP_Allowed_Tags_Generated { - 'tag_spec' => array( - 'extension_spec' => array( - 'bento' => array( -- 'has_css' => false, -+ 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-date-display', - 'requires_usage' => true, -@@ -16232,6 +16288,13 @@ class AMP_Allowed_Tags_Generated { - ), - 'tag_spec' => array( - 'extension_spec' => array( -+ 'bento' => array( -+ 'has_css' => false, -+ 'version' => '1.0', -+ ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-embedly-card', - 'requires_usage' => true, -@@ -16300,6 +16363,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-facebook', - 'requires_usage' => true, -@@ -16429,6 +16495,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-fit-text', - 'requires_usage' => true, -@@ -16930,6 +16999,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-inline-gallery', - 'requires_usage' => true, -@@ -16997,6 +17069,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-instagram', - 'requires_usage' => true, -@@ -17157,6 +17232,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-lightbox', - 'requires_usage' => true, -@@ -17193,6 +17271,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-lightbox-gallery', - 'requires_usage' => false, -@@ -18008,6 +18089,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => false, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '1.0', - 'name' => 'amp-render', - 'requires_usage' => true, -@@ -18105,6 +18189,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-selector', - 'requires_usage' => true, -@@ -18234,6 +18321,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-social-share', - 'requires_usage' => true, -@@ -18266,6 +18356,13 @@ class AMP_Allowed_Tags_Generated { - ), - 'tag_spec' => array( - 'extension_spec' => array( -+ 'bento' => array( -+ 'has_css' => false, -+ 'version' => '1.0', -+ ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-soundcloud', - 'requires_usage' => true, -@@ -18463,6 +18560,37 @@ class AMP_Allowed_Tags_Generated { - ), - ), - ), -+ array( -+ 'attr_spec_list' => array( -+ 'async' => array( -+ 'mandatory' => true, -+ 'value' => array( -+ '', -+ ), -+ ), -+ 'crossorigin' => array( -+ 'value' => array( -+ 'anonymous', -+ ), -+ ), -+ 'nonce' => array(), -+ 'type' => array( -+ 'value_casei' => array( -+ 'text/javascript', -+ ), -+ ), -+ ), -+ 'tag_spec' => array( -+ 'extension_spec' => array( -+ 'latest' => '0.1', -+ 'name' => 'amp-story-captions', -+ 'requires_usage' => true, -+ 'version' => array( -+ '0.1', -+ ), -+ ), -+ ), -+ ), - array( - 'attr_spec_list' => array( - 'async' => array( -@@ -18583,6 +18711,10 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ 'latest', -+ ), - 'latest' => '0.1', - 'name' => 'amp-stream-gallery', - 'requires_usage' => true, -@@ -18714,6 +18846,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-timeago', - 'requires_usage' => true, -@@ -18781,6 +18916,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-twitter', - 'requires_usage' => true, -@@ -18848,6 +18986,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-video', - 'requires_usage' => true, -@@ -18915,6 +19056,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-video-iframe', - 'requires_usage' => true, -@@ -18951,6 +19095,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-vimeo', - 'requires_usage' => true, -@@ -19138,6 +19285,14 @@ class AMP_Allowed_Tags_Generated { - ), - 'tag_spec' => array( - 'extension_spec' => array( -+ 'bento' => array( -+ 'has_css' => true, -+ 'version' => '1.0', -+ ), -+ 'bento_supported_version' => array( -+ '1.0', -+ 'latest', -+ ), - 'latest' => '1.0', - 'name' => 'amp-wordpress-embed', - 'requires_usage' => true, -@@ -19205,6 +19360,9 @@ class AMP_Allowed_Tags_Generated { - 'has_css' => true, - 'version' => '1.0', - ), -+ 'bento_supported_version' => array( -+ '1.0', -+ ), - 'latest' => '0.1', - 'name' => 'amp-youtube', - 'requires_usage' => true, -@@ -19692,7 +19850,6 @@ class AMP_Allowed_Tags_Generated { - 'doc_css_bytes' => false, - ), - 'tag_spec' => array( -- 'mandatory' => true, - 'mandatory_parent' => 'head', - 'spec_name' => 'head > style[amp-boilerplate]', - 'spec_url' => 'https://amp.dev/documentation/guides-and-tutorials/learn/spec/amp-boilerplate/?format=websites', -@@ -19715,7 +19872,6 @@ class AMP_Allowed_Tags_Generated { - 'doc_css_bytes' => false, - ), - 'tag_spec' => array( -- 'mandatory' => true, - 'mandatory_ancestor' => 'head', - 'mandatory_parent' => 'noscript', - 'spec_name' => 'noscript > style[amp-boilerplate]', -@@ -19759,6 +19915,55 @@ class AMP_Allowed_Tags_Generated { - 'unique' => true, - ), - ), -+ array( -+ 'attr_spec_list' => array( -+ 'amp-noscript' => array( -+ 'dispatch_key' => 1, -+ 'mandatory' => true, -+ 'value' => array( -+ '', -+ ), -+ ), -+ 'nonce' => array(), -+ 'type' => array( -+ 'value_casei' => array( -+ 'text/css', -+ ), -+ ), -+ ), -+ 'cdata' => array( -+ 'css_spec' => array( -+ 'allowed_at_rules' => array( -+ 'media', -+ 'page', -+ 'supports', -+ '-moz-document', -+ ), -+ 'declaration' => array(), -+ 'validate_keyframes' => false, -+ ), -+ 'disallowed_cdata_regex' => array( -+ array( -+ 'error_message' => 'html comments', -+ 'regex' => '