Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid failing validation requests when response is redirect #6069

Merged
merged 3 commits into from
Apr 14, 2021

Conversation

westonruter
Copy link
Member

Summary

This fixes a regression introduced by ae36769 in #5296 whereby a validation request returned JSON error data if the response was not an AMP page. An exception is needed for when the response is not an AMP page and yet is an HTTP redirect. The \AMP_Validation_Manager::validate_url() follows redirects, so we should allow redirects to pass through.

I discovered this when trying to do wp amp validation run --limit=1 --include=is_date which resulted in:

Warning: Validate URL error (RENDERED_PAGE_NOT_AMP): The requested URL did not result in an AMP page being rendered. URL: https://wordpressdev.lndo.site/?year=2021

This fixes that problem by allowing the request for https://wordpressdev.lndo.site/?year=2021 to redirect to https://wordpressdev.lndo.site/2021/.

Also amends #6063 by undoing erroneous addition of is_callable() check in d0d2137.

Checklist

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

@westonruter westonruter added this to the v2.1 milestone Apr 14, 2021
@codecov
Copy link

codecov bot commented Apr 14, 2021

Codecov Report

Merging #6069 (ca1196e) into develop (8dad6e3) will decrease coverage by 0.00%.
The diff coverage is 62.50%.

❗ Current head ca1196e differs from pull request most recent head f634910. Consider uploading reports for the commit f634910 to get more accurate results
Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #6069      +/-   ##
=============================================
- Coverage      74.82%   74.81%   -0.01%     
- Complexity      5767     5771       +4     
=============================================
  Files            230      230              
  Lines          17486    17492       +6     
=============================================
+ Hits           13084    13087       +3     
- Misses          4402     4405       +3     
Flag Coverage Δ Complexity Δ
javascript 79.84% <ø> (ø) 0.00 <ø> (ø)
php 74.58% <62.50%> (-0.01%) 5771.00 <0.00> (+4.00) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
includes/class-amp-theme-support.php 85.90% <57.14%> (-0.30%) 249.00 <0.00> (+5.00) ⬇️
src/Infrastructure/ServiceBasedPlugin.php 85.51% <100.00%> (ø) 56.00 <0.00> (-1.00)

includes/class-amp-theme-support.php Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Apr 14, 2021

Plugin builds for f634910 are ready 🛎️!

Co-authored-by: Alain Schlesser <[email protected]>
@westonruter westonruter merged commit 905ca69 into develop Apr 14, 2021
@westonruter westonruter deleted the fix/amp-validation-of-redirect branch April 14, 2021 19:56
@pierlon pierlon self-assigned this Apr 24, 2021
@pierlon
Copy link
Contributor

pierlon commented Apr 26, 2021

QA Passed

Running the command wp amp validation run --limit=1 --include=is_date no longer results in the warning "Validate URL error (RENDERED_PAGE_NOT_AMP)" from occurring, and the URL is validated:

Success: 0 crawled URLs have invalid markup kept out of 1 total with AMP validation issue(s); 1 URLs were crawled.
+--------------------------+-----------+---------------+
| Template or content type | URL Count | Validity Rate |
+--------------------------+-----------+---------------+
| date                     | 1         | 100%          |
+--------------------------+-----------+---------------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants