-
Notifications
You must be signed in to change notification settings - Fork 384
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
Refactor storage of validation errors to use taxonomy terms #1093
Conversation
The “At a Glance” widget now shows the number of URLs that contain any new errors (which haven't yet been acknowledged or ignored): Likewise, the number appearing with the “Invalid Pages” admin menu item also is now the number of invalid URLs which contain at least one new validation error. You can also now filter Invalid Pages (URLs) by those which contain at least one new, acknowledged, or ignored error: And lastly, when listing out the validation errors for a given invalid URL it will now show whether a given error has been acknowledged or ignored, or if it is new. If it is new then the error details are initially expanded. Otherwise, they are initially collapsed: Next step here is to allow a user to switch the status of a given validation error inline when looking at the list of validation errors for a given invalid URL. |
This is awesome @westonruter, such a great step forward! First round feedback:
|
Actually, “acknowledge” has the same effect as “new”: both are blockers. The difference is that “new” is like unread. The idea is that maybe a user would like to default the behavior of new validation errors to be ignored by default instead of acknowledged by default. I tried to initially explain what acknowledging means in
I'm not totally sold on the naming of “acknowledge” and “ignore” but I couldn't think of anything better.
Agreed. I've got this jotted down as a todo item. |
You're right. Unfortunately Update: Fixed in ac8fd64 (via workaround). |
The edit post screen for an Invalid AMP Page now displays its actual URL and as a link so you can visit the URL to review the post on the frontend. (The view URL will need to be getting an The URL shown in the post list table is also now shortened to remove the scheme and host name: |
@westonruter I took some time today going over the whole validation system, and it's crazy cool! Some feedback. A suggestion on terminology. It seams that Ignore and Acknowledge is similar. Perhaps The confirmation messages also made me feel a little confused |
$node->parentNode->removeChild( $node ); | ||
} | ||
return $should_remove; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In canonical AMP, whenever $should_remove
is false
, then this needs to trigger dirty AMP mode, where amp
attribute is removed from the html
element.
9a546b3
to
811d133
Compare
dd3f2ff
to
9365a6b
Compare
* Add get_validation_error_count() method. * Add removable_query_args to prevent persisting on page
…statuses * Add recognition of amp_validation_error_status query var for amp_invalid_url post queries. * Indicate in the list of errors on a given invalid URL post which are new, ignored, or acknowledged.
…valid URL details
…deletion of non-zero-count terms
Add query vars to removable list
…ource comments * Introduce amp_preserve_source_comments query param. * Rename locate_sources arg to should_locate_sources. * Remove debug flag for preventing sanitization on all validation errors. * Rename add_validation_hooks method to add_validation_error_sourcing.
… when sanitization status changes
Fix additional static analysis issues
Allow passing nonce instead of auth cookie to with amp_validate requests.
41570b0
to
90eff4f
Compare
With 69055c0, it is now made explicit that accepting a validation error on one URL will apply to the same error that occurs on other URLs : |
Let statuses be changed in bulk on invalid URL screen
I've added the rudimentary ability to preview changes to the statuses of validation errors: Clicking “Preview” takes you to a URL like:
You can see how the URL behaves with any number of validation errors accepted (sanitized). Again, the UI for the invalid URLs screen and validation errors screen needs to be completely redone. The UI code in place now should be considered a prototype. Ideally there would be REST API endpoints added for managing the validation error status and invalid URL posts, and the current screens for managing them should be refactored to use a JS-based interface, such as with React. @ThierryA Given these known issues with the UI and the outstanding need to update unit tests (which will likely change greatly with changes to the UI) I suggest getting this merged sooner rather than later, and then we can follow up with additional PRs to iterate on what is included here. |
* Use wp_json_encode() instead or serialize(). * Ensure window opened for previewing validation error term status changes to have consistent name. * Use VALIDATION_ERROR_TERM_STATUS_QUERY_VAR constant.
5e12fa1
to
a4312b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Hi @westonruter,
Great work here. This PR looks good, having done a sanity-check review. The UI for "Accepted" and "Rejected" also looks much better
There are a few points, but no blocker from my perspective.
@@ -89,7 +89,9 @@ class AMP_Autoloader { | |||
'AMP_DOM_Utils' => 'includes/utils/class-amp-dom-utils', | |||
'AMP_HTML_Utils' => 'includes/utils/class-amp-html-utils', | |||
'AMP_Image_Dimension_Extractor' => 'includes/utils/class-amp-image-dimension-extractor', | |||
'AMP_Validation_Utils' => 'includes/utils/class-amp-validation-utils', | |||
'AMP_Validation_Manager' => 'includes/validation/class-amp-validation-manager', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice how this is now organized in the includes/validation/
directory.
); | ||
|
||
$cache_key = md5( $stylesheet . serialize( $cache_impacting_options ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize | ||
$cache_key = md5( $stylesheet . wp_json_encode( $cache_impacting_options ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice how using wp_json_encode()
removes the need to ignore a phpcs
violation.
$result[] = esc_html( sprintf( | ||
/* translators: %s is count */ | ||
__( '❓ New: %s', 'amp' ), | ||
number_format_i18n( $counts[ AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_STATUS ] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of number_format_i18(), I didn't know about that.
// Guard against Kses from corrupting content by adding post_content after content_save_pre filter applies. | ||
$insert_post_content = function( $post_data ) use ( $placeholder, $post_content ) { | ||
$should_supply_post_content = ( | ||
isset( $post_data['post_content'] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this line could also check $post_data['post_type']
, instead of the isset( $post_data['post_type'] )
check 4 lines below:
isset( $post_data['post_content'], $post_data['post_type'] )
@@ -1,12 +1,12 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to eventually move these tests to separate files, like test-class-amp-validation-manager.php
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely agree. We'll follow up with new PR to add/update the tests and also to polish the UI. 👍
It seems there are networking connectivity issues being experienced by GitHub or Travis that are causing jobs to fail. I'm going to go ahead and merge this even though the build isn't finishing. |
This will include the plumbing to be able to achieve dynamically allowing AMP responses based on validation status (#1087). It should include the ability to acknowledge a certain validation error as being ignored (#1003, #1063).
term_group
) for acknowledged and ignored, with ability for user to change them.sources
to be stored in theamp_invalid_url
posts themselves. This addresses issue with validation errors having dynamic sources, such aspost_id
.script
contents in validation errors. Fixes Capture script tag contents in AMP validator errors #1031.enqueued_script
validation error intoremoved_element
validation error, combiningsources
into latter.document.write
is disabled for sake ofamp-live-list
.Fixes #1003.
Fixes #1087.