ampproject / amp-wp

Enable AMP on your WordPress site, the WordPress way.
https://wordpress.org/plugins/amp/
GNU General Public License v2.0
1.79k stars 383 forks source link

wp-polyfill-inert missing data-ampdevmode attribute #7595

Closed milindmore22 closed 1 year ago

milindmore22 commented 1 year ago

Bug Description

As reported by a user on the support topic, the AMP validation is flagging wp-polyfill-inert.js as invalidation.

I tested for the same in my test site and I am able to reproduce the issue in translation mode and Reader Mode.

    "node_name": "script",
    "parent_name": "body",
    "code": "DISALLOWED_TAG",
    "type": "js_error",
    "node_attributes": {
        "src": "https://amp-support.rt.gw/wp-includes/js/dist/vendor/wp-polyfill-inert.js?ver=__normalized__",
        "id": "wp-polyfill-inert-js"
    },
    "node_type": "ELEMENT",
    "sources": [
        {
            "type": "plugin",
            "name": "amp",
            "file": "src/Admin/PairedBrowsing.php",
            "line": 155,
            "function": "AmpProject\\AmpWP\\Admin\\PairedBrowsing::init_frontend",
            "hook": "wp",
            "priority": 9223372036854776000,
            "dependency_type": "script",
            "handle": "amp-paired-browsing-client",
            "dependency_handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "script-loader.php",
            "line": 626,
            "function": "wp_default_packages",
            "hook": "wp_default_scripts",
            "priority": 10,
            "dependency_type": "script",
            "handle": "wp-dom-ready",
            "dependency_handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "class-wp-widget-factory.php",
            "line": 90,
            "function": "WP_Widget_Factory::_register_widgets",
            "hook": "widgets_init",
            "priority": 100,
            "dependency_type": "script",
            "handle": "wp-dom-ready",
            "dependency_handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "widgets.php",
            "line": 1804,
            "function": "wp_widgets_init",
            "hook": "init",
            "priority": 1,
            "dependency_type": "script",
            "handle": "wp-dom-ready",
            "dependency_handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "script-loader.php",
            "line": 626,
            "function": "wp_default_packages",
            "hook": "wp_default_scripts",
            "priority": 10,
            "dependency_type": "script",
            "handle": "wp-polyfill",
            "dependency_handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "class-wp-widget-factory.php",
            "line": 90,
            "function": "WP_Widget_Factory::_register_widgets",
            "hook": "widgets_init",
            "priority": 100,
            "dependency_type": "script",
            "handle": "wp-polyfill",
            "dependency_handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "widgets.php",
            "line": 1804,
            "function": "wp_widgets_init",
            "hook": "init",
            "priority": 1,
            "dependency_type": "script",
            "handle": "wp-polyfill",
            "dependency_handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "script-loader.php",
            "line": 626,
            "function": "wp_default_packages",
            "hook": "wp_default_scripts",
            "priority": 10,
            "dependency_type": "script",
            "handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "class-wp-widget-factory.php",
            "line": 90,
            "function": "WP_Widget_Factory::_register_widgets",
            "hook": "widgets_init",
            "priority": 100,
            "dependency_type": "script",
            "handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "widgets.php",
            "line": 1804,
            "function": "wp_widgets_init",
            "hook": "init",
            "priority": 1,
            "dependency_type": "script",
            "handle": "wp-polyfill-inert"
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "script-loader.php",
            "line": 2171,
            "function": "wp_print_footer_scripts",
            "hook": "wp_footer",
            "priority": 20
        },
        {
            "type": "core",
            "name": "wp-includes",
            "file": "script-loader.php",
            "line": 2161,
            "function": "_wp_footer_scripts",
            "hook": "wp_print_footer_scripts",
            "priority": 10
        }
    ],
    "removed": true,
    "reviewed": false
}

Primary Theme: TwentyTwenty Reader Mode Theme: Astra

We need to add additional handle wp-polyfill-inert to the list

Expected Behaviour

There should not be any validation error for core scripts the script should be included using devmode attribute data-ampdevmode

Screenshots

image

PHP Version

8.0

Plugin Version

2.4.2

AMP plugin template mode

Transitional, Reader

WordPress Version

6.2.2

Site Health

### wp-core ###

version: 6.2.2
site_language: en_US
user_language: en_US
timezone: -07:00
permalink: /%year%/%monthnum%/%day%/%postname%/
https_status: true
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: open
environment_type: production
user_count: 3
dotorg_communication: true

### wp-paths-sizes ###

wordpress_path: /var/www/htdocs/current
wordpress_size: 241.96 MB (253709601 bytes)
uploads_path: /var/www/htdocs/current/wp-content/uploads
uploads_size: 250.35 MB (262514776 bytes)
themes_path: /var/www/htdocs/current/wp-content/themes
themes_size: 101.31 MB (106227142 bytes)
plugins_path: /var/www/htdocs/current/wp-content/plugins
plugins_size: 333.59 MB (349791258 bytes)
database_size: 22.28 MB (23363584 bytes)
total_size: 949.48 MB (995606361 bytes)

### wp-active-theme ###

name: Twenty Twenty (twentytwenty)
version: 2.2
author: the WordPress team
author_website: https://wordpress.org/
parent_theme: none
theme_features: core-block-patterns, widgets-block-editor, automatic-feed-links, custom-background, post-thumbnails, custom-logo, title-tag, html5, align-wide, responsive-embeds, customize-selective-refresh-widgets, editor-color-palette, editor-font-sizes, editor-styles, amp, widgets, menus, editor-style
theme_path: /var/www/htdocs/current/wp-content/themes/twentytwenty
auto_update: Disabled

### wp-themes-inactive (25) ###

Newspaper: version: 12.4, author: tagDiv, Auto-updates disabled
Astra: version: 4.1.6, author: Brainstorm Force, Auto-updates disabled
Davis Blocks: version: 0.2, author: Anders Norén, Auto-updates disabled
Design Mode: version: 1.0.3, author: Brian Gardner, Auto-updates disabled
Flatsome Child: version: 3.0, author: UX Themes, Auto-updates disabled
Flatsome: version: 3.16.1, author: UX-Themes, Auto-updates disabled
GeneratePress: version: 3.3.0, author: Tom Usborne, Auto-updates disabled
Jannah: version: 5.4.10, author: TieLabs, Auto-updates disabled
Kadence: version: 1.1.40, author: Kadence WP, Auto-updates disabled
Magnitude: version: 2.0.1, author: AF themes, Auto-updates disabled
Neve: version: 3.6.5, author: ThemeIsle, Auto-updates disabled
Newspack: version: 1.39.3, author: Automattic, Auto-updates disabled
Storefront: version: 4.4.1, author: Automattic, Auto-updates disabled
TT1 Blocks: version: 0.4.8, author: the WordPress team, Auto-updates disabled
Twenty Eleven: version: 4.3, author: the WordPress team, Auto-updates disabled
Twenty Fourteen: version: 3.6, author: the WordPress team, Auto-updates disabled
Twenty Nineteen: version: 2.5, author: the WordPress team, Auto-updates disabled
Twenty Seventeen: version: 3.2, author: the WordPress team, Auto-updates disabled
Twenty Sixteen: version: 2.9, author: the WordPress team, Auto-updates disabled
Twenty Twelve: version: 3.9, author: the WordPress team, Auto-updates disabled
Twenty Twenty-One: version: 1.8, author: the WordPress team, Auto-updates disabled
Twenty Twenty-Three: version: 1.1, author: the WordPress team, Auto-updates disabled
Twenty Twenty-Two: version: 1.4, author: the WordPress team, Auto-updates disabled
Underscore: version: 1.0.0, author: Underscores.me, Auto-updates disabled
Zakra: version: 3.0.0.5, author: ThemeGrill, Auto-updates disabled

### wp-plugins-active (2) ###

AMP: version: 2.4.2, author: AMP Project Contributors, Auto-updates disabled
Login with Google: version: 1.3.1, author: rtCamp, Auto-updates disabled

### wp-plugins-inactive (43) ###

Ad Inserter: version: 2.7.30, author: Igor Funa, Auto-updates disabled
AMP compatibility for PDF Embedder.: version: 0.1, author: milindmore22, Google, Auto-updates disabled
AMP Disable ES Modules by Default: version: 0.1, author: Weston Ruter, Auto-updates disabled
AMP Enhancer: version: 1.0.48, author: ampenhancer, Auto-updates disabled
AMP for GeneratePress: version: 0.2, author: Tom Usborne, Auto-updates disabled
AMP Generic Compat: version: 0.2, author: milindmore22, Auto-updates disabled
AMP Plugin Name Compat: version: 0.1, author: Your Name, Google, Auto-updates disabled
AMP Popup: version: 0.1, author: Your Name Here, Auto-updates disabled
AMP Tawk.to Chat: version: 0.1, author: milindmore22, rtCamp, Google, Auto-updates disabled
Autoptimize: version: 3.1.8.1, author: Frank Goossens (futtta), Auto-updates disabled
Blog2Social: Social Media Auto Post & Scheduler: version: 7.2.1, author: Blog2Social, Adenion, Auto-updates disabled
Classic Editor: version: 1.6.3, author: WordPress Contributors, Auto-updates disabled
Classic Widgets: version: 0.3, author: WordPress Contributors, Auto-updates disabled
Contact Form 7: version: 5.7.7, author: Takayuki Miyoshi, Auto-updates disabled
Disable AMP to AMP Linking.: version: 1.0, author: AMP Support, Auto-updates disabled
Gravity Forms: version: 2.6.7, author: Gravity Forms, Auto-updates disabled
Gutenberg: version: 16.3.0, author: Gutenberg Team, Auto-updates disabled
Jetpack: version: 12.4, author: Automattic, Auto-updates disabled
Jetpack Boost: version: 2.0.0, author: Automattic - Jetpack Site Speed team, Auto-updates disabled
Kadence Starter Templates: version: 1.2.21, author: Kadence WP, Auto-updates disabled
LiteSpeed Cache: version: 5.5.1, author: LiteSpeed Technologies, Auto-updates disabled
OneSignal Push Notifications: version: 2.4.0, author: OneSignal, Auto-updates disabled
PDF Embedder: version: 4.6.4, author: WP PDF Embedder Team, Auto-updates disabled
Performance Lab: version: 2.5.0, author: WordPress Performance Team, Auto-updates disabled
Really Simple CAPTCHA: version: 2.2, author: Takayuki Miyoshi, Auto-updates disabled
Regenerate Thumbnails: version: 3.1.5, author: Alex Mills (Viper007Bond), Auto-updates disabled
Schema & Structured Data for WP & AMP: version: 1.17, author: Magazine3, Auto-updates disabled
Site Kit by Google: version: 1.106.0, author: Google, Auto-updates disabled
tagDiv Cloud Library: version: 2.7 | built on 18.05.2023 11:25, author: tagDiv, Auto-updates disabled
tagDiv Composer: version: 4.1 | built on 18.05.2023 11:25, author: tagDiv, Auto-updates disabled
tagDiv Social Counter: version: 5.2 | built on 15.02.2023 13:25, author: tagDiv, Auto-updates disabled
User Switching: version: 1.7.0, author: John Blackbourn & contributors, Auto-updates disabled
W3 Total Cache: version: 2.3.3, author: BoldGrid, Auto-updates disabled
Web Stories: version: 1.33.0, author: Google, Auto-updates disabled
WooCommerce: version: 7.9.0, author: Automattic, Auto-updates disabled
WordPress Importer: version: 0.8.1, author: wordpressdotorg, Auto-updates disabled
WP Crontrol: version: 1.15.3, author: John Blackbourn & crontributors, Auto-updates disabled
WP Downgrade | Specific Core Version: version: 1.2.6, author: Reisetiger, Auto-updates disabled
WP Fastest Cache: version: 1.1.7, author: Emre Vona, Auto-updates disabled
WPForms Lite: version: 1.8.2.3, author: WPForms, Auto-updates disabled
WP Rollback: version: 1.7.3, author: GiveWP.com, Auto-updates disabled
WP Super Cache: version: 1.9.4, author: Automattic, Auto-updates disabled
Yoast SEO: version: 20.12, author: Team Yoast, Auto-updates disabled

### wp-media ###

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1691
imagemagick_version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
imagick_version: 3.7.0
file_uploads: File uploads is turned off
post_max_size: 100M
upload_max_filesize: 100M
max_effective_size: 100 MB
max_file_uploads: 20
imagick_limits: 
    imagick::RESOURCETYPE_AREA: 122 MB
    imagick::RESOURCETYPE_DISK: 1073741824
    imagick::RESOURCETYPE_FILE: 786432
    imagick::RESOURCETYPE_MAP: 512 MB
    imagick::RESOURCETYPE_MEMORY: 256 MB
    imagick::RESOURCETYPE_THREAD: 1
    imagick::RESOURCETYPE_TIME: 9.2233720368548E+18
imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HEIC, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
gd_version: bundled (2.1.0 compatible)
gd_formats: GIF, JPEG, PNG, WebP, BMP
ghostscript_version: not available

### wp-server ###

server_architecture: Linux 5.4.0-96-generic x86_64
httpd_software: nginx/1.21.4
php_version: 8.0.27 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 300
memory_limit: 128M
admin_memory_limit: 256M
max_input_time: 60
upload_max_filesize: 100M
php_post_max_size: 100M
curl_version: 7.74.0 OpenSSL/1.1.1n
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: true

### wp-database ###

extension: mysqli
server_version: 10.11.2-MariaDB-1:10.11.2+maria~ubu2204
client_version: mysqlnd 8.0.27
max_allowed_packet: 16777216
max_connections: 151

### wp-constants ###

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /var/www/htdocs/current/wp-content
WP_PLUGIN_DIR: /var/www/htdocs/current/wp-content/plugins
WP_MEMORY_LIMIT: 40M
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: true
WP_DEBUG_DISPLAY: false
WP_DEBUG_LOG: true
SCRIPT_DEBUG: true
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: Undefined
DB_CHARSET: utf8mb4
DB_COLLATE: undefined

### wp-filesystem ###

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable

### amp_wp ###

amp_slug_query_var: amp
amp_slug_defined_late: false
amp_mode_enabled: reader
amp_reader_theme: astra
amp_templates_enabled: post, page, is_singular, is_archive, is_author, is_date, is_category, is_tag
amp_serve_all_templates: false
amp_css_transient_caching_disabled: false
amp_css_transient_caching_threshold: 5000 transients per day
amp_css_transient_caching_sampling_range: 14 days
amp_css_transient_caching_transient_count: 167
amp_css_transient_caching_time_series: 
    20230720: 66
    20230721: 75
    20230722: 75
    20230723: 75
    20230724: 75
    20230725: 118
    20230726: 128
    20230727: 128
    20230728: 145
    20230729: 145
    20230730: 142
    20230731: 142
    20230801: 142
    20230802: 165
amp_libxml_version: 2.9.10

Gutenberg Version

No response

OS(s) Affected

No response

Browser(s) Affected

No response

Device(s) Affected

No response

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

pavanpatil1 commented 11 months ago

QA Passed ✅

Verified the fix and it working fine. The invalidation error related to the wp-polyfill-inert.js is not visible now.

Before fix After fix
image image