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

Update validation model with auto-accepted (instead of forcibly sanitized) and statuses for new-accepted/new-rejected #1429

Merged
merged 30 commits into from Sep 21, 2018
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fe33e95
Rename force-sanitization to auto-accept-sanitization
westonruter Sep 13, 2018
aed7380
Split new status into new-accepted and new-rejected
westonruter Sep 14, 2018
8f6a26e
Update options related to auto-sanitization
westonruter Sep 14, 2018
58d03c9
Update term list table styling for validation errors
westonruter Sep 15, 2018
de7b04b
Eliminate forced sanitization with special with_option case; incorpor…
westonruter Sep 15, 2018
a3d442d
Add support for querying multiple term statuses at a time; use for New
westonruter Sep 16, 2018
c2193fb
Merge branch 'develop' of https://github.com/Automattic/amp-wp into u…
westonruter Sep 16, 2018
4375a40
Update display of edit post screen notices for AMP validation errors
westonruter Sep 16, 2018
5bd1ea7
Merge branch 'develop' of https://github.com/Automattic/amp-wp into u…
westonruter Sep 17, 2018
1ed50f2
Partially revert de7b04b to restore omission of forcibly-sanitized er…
westonruter Sep 17, 2018
b057e46
Merge branch 'develop' of https://github.com/Automattic/amp-wp into u…
westonruter Sep 17, 2018
e8e550e
WIP
westonruter Sep 17, 2018
06e3d4d
Introduce AMP_Validation_Error_Taxonomy::sanitize_term_status() to de…
westonruter Sep 18, 2018
c1e0658
Refactor duplicated SQL prepare for IN condition
westonruter Sep 18, 2018
e5274ac
Remove amp attribute from html element on non-AMP documents
westonruter Sep 18, 2018
d334f2a
Show preview button on amp_invalid_url screen in native mode
westonruter Sep 18, 2018
0d6781e
Add link to validation errors screen for bulk acceptance
westonruter Sep 18, 2018
9493858
Fix PHP 5.2 error with call to protected method in closure
westonruter Sep 18, 2018
70e9cbf
Add wp amp reset-site-validation command to purge site of validation …
westonruter Sep 18, 2018
85d1641
Eliminate trashing for invalid URL posts
westonruter Sep 18, 2018
3ea0df5
Add AMP_Validation_Error_Taxonomy::get_term() method to reduce code d…
westonruter Sep 19, 2018
b5fc798
Discontinue hiding validation errors that have no URL counts
westonruter Sep 19, 2018
827503b
Add ability to clear empty validation error terms
westonruter Sep 20, 2018
f8f7db0
Merge branch 'develop' of https://github.com/Automattic/amp-wp into u…
westonruter Sep 20, 2018
e8c4e8a
Update status constants which were missed in merge conflict resolution
westonruter Sep 20, 2018
273a00b
Make single-error-detail open by default
westonruter Sep 20, 2018
a272ce6
Merge branch 'develop' of https://github.com/Automattic/amp-wp into u…
westonruter Sep 21, 2018
945e763
Show accepted/rejected in new status option and disable it
westonruter Sep 21, 2018
276c5a5
Make the 'Status' column wider, to fit the icon and <select>
kienstra Sep 21, 2018
cd20106
Remove a (trivial) artifiact from a merge conflict
kienstra Sep 21, 2018
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+25 −20
Diff settings

Always

Just for now

Update display of edit post screen notices for AMP validation errors

* Show notice when there are rejected validation errors which are new or acknowledged.
* Update messages based on simplified logic for serving non-AMP native with errors.
  • Loading branch information...
westonruter committed Sep 16, 2018
commit 4375a40fbbc6413130ddf5691c0096a74eb7022c
@@ -145,7 +145,7 @@ var ampBlockValidation = ( function() { // eslint-disable-line no-unused-vars
* @return {void}
*/
handleValidationErrorsStateChange: function handleValidationErrorsStateChange() {
var currentPost, validationErrors, blockValidationErrors, noticeElement, noticeMessage, blockErrorCount, ampValidity, hasActuallyUnacceptedError;
var currentPost, validationErrors, blockValidationErrors, noticeElement, noticeMessage, blockErrorCount, ampValidity;

if ( ! module.isAMPEnabled() ) {
if ( ! module.lastStates.noticesAreReset ) {
@@ -161,15 +161,17 @@ var ampBlockValidation = ( function() { // eslint-disable-line no-unused-vars
return;
}

hasActuallyUnacceptedError = false;
currentPost = wp.data.select( 'core/editor' ).getCurrentPost();
ampValidity = currentPost[ module.data.ampValidityRestField ] || {};

// Show all validation errors which have not been explicitly acknowledged as accepted.
validationErrors = _.map(
_.filter( ampValidity.results, function( result ) {
if ( result.status !== 1 /* ACCEPTED */ ) {
hasActuallyUnacceptedError = true;
}
return result.term_status !== 1; // ACCEPTED
return (
0 /* \AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_REJECTED_STATUS */ === result.status ||
1 /* \AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_ACCEPTED_STATUS */ === result.status ||
2 /* \AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACK_REJECTED_STATUS */ === result.status // eslint-disable-line no-magic-numbers // @todo Show differently since moderated?
);
} ),
function( result ) {
return result.error;
@@ -192,8 +194,8 @@ var ampBlockValidation = ( function() { // eslint-disable-line no-unused-vars

noticeMessage = wp.i18n.sprintf(
wp.i18n._n(
'There is %s issue from AMP validation.',
'There are %s issues from AMP validation.',
'There is %s issue from AMP validation which needs review.',
'There are %s issues from AMP validation which need review.',
validationErrors.length,
'amp'
),
@@ -239,10 +241,10 @@ var ampBlockValidation = ( function() { // eslint-disable-line no-unused-vars
}

noticeMessage += ' ';
if ( hasActuallyUnacceptedError && ! module.data.isCanonical ) {
noticeMessage += wp.i18n.__( 'Non-accepted validation errors prevent AMP from being served, and the user will be redirected to the non-AMP version.', 'amp' );
if ( module.data.isCanonical ) {
noticeMessage += wp.i18n.__( 'Non-accepted validation errors prevent AMP from being served.', 'amp' );
} else {
noticeMessage += wp.i18n.__( 'The invalid markup will be automatically sanitized to ensure a valid AMP response is served.', 'amp' );
noticeMessage += wp.i18n.__( 'Non-accepted validation errors prevent AMP from being served, and the user will be redirected to the non-AMP version.', 'amp' );
}

noticeElement = wp.element.createElement( 'p', {}, [
@@ -787,14 +787,16 @@ public static function print_edit_form_validation_status( $post ) {
return;
}
$has_actually_unaccepted_error = false;
$validation_errors = array();
// Show all validation errors which have not been explicitly acknowledged as accepted.
$validation_errors = array();
foreach ( AMP_Invalid_URL_Post_Type::get_invalid_url_validation_errors( $invalid_url_post ) as $error ) {
if ( AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACK_ACCEPTED_STATUS !== $error['term_status'] ) {
$needs_moderation = (
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACK_REJECTED_STATUS === $error['status'] || // @todo Show differently since moderated?
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_REJECTED_STATUS === $error['status'] ||
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_ACCEPTED_STATUS === $error['status']
);
if ( $needs_moderation ) {
$validation_errors[] = $error['data'];
if ( AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACK_ACCEPTED_STATUS !== $error['status'] ) {
$has_actually_unaccepted_error = true;
}
}
}
@@ -805,12 +807,13 @@ public static function print_edit_form_validation_status( $post ) {
echo '<div class="notice notice-warning">';
echo '<p>';
// @todo Check if the error actually occurs in the_content, and if not, consider omitting the warning if the user does not have privileges to manage_options.
esc_html_e( 'There is content which fails AMP validation.', 'amp' );
echo ' ';
if ( $has_actually_unaccepted_error && ! amp_is_canonical() ) {
esc_html_e( 'Non-accepted validation errors prevent AMP from being served, and the user will be redirected to the non-AMP version.', 'amp' );
if ( amp_is_canonical() ) {
esc_html_e( 'Non-accepted validation errors prevent AMP from being served.', 'amp' );
} else {
esc_html_e( 'The invalid markup will be automatically sanitized to ensure a valid AMP response is served.', 'amp' );
esc_html_e( 'Non-accepted validation errors prevent AMP from being served, and the user will be redirected to the non-AMP version.', 'amp' );
}
echo sprintf(
' <a href="%s" target="_blank">%s</a>',
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.