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

Move validation background tasks behind feature flag filter until Site Scanning is implemented #5892

Merged
merged 3 commits into from
Feb 19, 2021

Conversation

westonruter
Copy link
Member

I've been thinking about the new cron jobs for checking site validation, specifically these introduced in #5515 for #1756:

  • The amp_validate_urls cron which checks a sample set of URLs.
  • The amp_single_post_validate cron which checks a URL after a post is published and the user doesn't have DevTools enabled.

At the moment, these two cron jobs are responsible for generating validation data which we are not yet using. We do not have the aforementioned notification center to communicate AMP Site Health and we haven't yet implemented Site Scanning as part of the onboarding wizard. Validation data is being generated even when DevTools is disabled now. This causes a problem also because we don't have any garbage collection of validation data (#4779). Therefore, since we aren't using the output of these additional validation checks, I propose that we put them behind a feature flag (internal filter) and turn them off for 2.1. This will allow us to punt a couple more issues to 2.2 to coincide with Site Scanning which is what they are the foundation for. Specifically #5750 and #4779.

@westonruter westonruter added WS:Core Work stream for Plugin core Site Scanning labels Feb 18, 2021
@westonruter westonruter added this to the v2.1 milestone Feb 18, 2021
@codecov
Copy link

codecov bot commented Feb 18, 2021

Codecov Report

Merging #5892 (850e6de) into develop (d12bd98) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #5892      +/-   ##
=============================================
- Coverage      75.16%   75.12%   -0.04%     
- Complexity      5665     5667       +2     
=============================================
  Files            210      210              
  Lines          17019    17023       +4     
=============================================
- Hits           12792    12789       -3     
- Misses          4227     4234       +7     
Flag Coverage Δ Complexity Δ
javascript 75.13% <ø> (ø) 0.00 <ø> (ø)
php 75.12% <100.00%> (-0.04%) 0.00 <2.00> (ø)

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

Impacted Files Coverage Δ Complexity Δ
src/Validation/SavePostValidationEvent.php 91.66% <100.00%> (-2.46%) 18.00 <1.00> (+1.00) ⬇️
src/Validation/URLValidationCron.php 73.68% <100.00%> (-20.44%) 8.00 <1.00> (+1.00) ⬇️
...c/BackgroundTask/SingleScheduledBackgroundTask.php 83.33% <0.00%> (-16.67%) 5.00% <0.00%> (ø%)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2021

Plugin builds for f12c5d5 are ready 🛎️!

Copy link
Contributor

@pierlon pierlon left a comment

Choose a reason for hiding this comment

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

On second thought, I think the related tests should be updated accordingly.

@pierlon
Copy link
Contributor

pierlon commented Feb 18, 2021

Updated tests in f12c5d5.

@westonruter westonruter merged commit e35e936 into develop Feb 19, 2021
@westonruter westonruter deleted the disable/validation-background-tasks branch February 19, 2021 06:53
@pierlon pierlon self-assigned this Apr 27, 2021
@pierlon
Copy link
Contributor

pierlon commented Apr 27, 2021

QA Passed

Getting a list of scheduled cron events with wp cron event list does not include the amp_validate_urls nor amp_single_post_validate cron hooks.

After activating a plugin with the following filter:

add_filter( 'amp_temp_validation_cron_tasks_enabled', '__return_true' );

I verified that the amp_validate_urls hook was scheduled by running wp cron event list:

+------------------------------------+---------------------+-----------------------+------------+
| hook                               | next_run_gmt        | next_run_relative     | recurrence |
+------------------------------------+---------------------+-----------------------+------------+
| amp_validate_urls                  | 2021-04-27 17:58:59 | now                   | 1 day      |
+------------------------------------+---------------------+-----------------------+------------+

To verify that the amp_single_post_validate cron event is being scheduled, I added a filter to capture cron events before they're scheduled:

add_filter( 'pre_schedule_event', function ( $pre, $event ) {
	error_log( 'Scheduling: ' . $event->hook );
	return $pre;
}, 10, 2 );

When Developer Tools is disabled and I go to publish a post, I can see that the line Scheduling: amp_single_post_validate was logged, confirming that the cron event was scheduled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Site Scanning WS:Core Work stream for Plugin core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants