Skip to content

Commit

Permalink
Store full validation error in invalid URL post for sake of searching
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jun 1, 2018
1 parent 2831654 commit 3b484e8
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions includes/validation/class-amp-invalid-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,12 @@ public static function get_invalid_url_validation_errors( $post, $args = array()
continue;
}
$term = get_term_by( 'slug', $stored_validation_error['term_slug'], AMP_Validation_Error_Taxonomy::TAXONOMY_SLUG );
if ( ! $term ) {
continue;
}
if ( $args['ignore_accepted'] && AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACCEPTED_STATUS === $term->term_group ) {
if ( $term && $args['ignore_accepted'] && AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_ACCEPTED_STATUS === $term->term_group ) {
continue;
}
$errors[] = array(
'term' => $term,
'data' => array_merge(
json_decode( $term->description, true ),
array(
'sources' => $stored_validation_error['sources'],
)
),
'data' => $stored_validation_error['data'],
);
}
return $errors;
Expand Down Expand Up @@ -318,15 +310,6 @@ public static function store_validation_errors( $validation_errors, $url ) {

$terms = array();
foreach ( $validation_errors as $data ) {
/*
* Exclude sources from data since not available unless sources are being obtained,
* and thus not able to be matched when hashed.
*/
$sources = null;
if ( isset( $data['sources'] ) ) {
$sources = $data['sources'];
}

$term_data = AMP_Validation_Error_Taxonomy::prepare_validation_error_taxonomy_term( $data );
$term_slug = $term_data['slug'];
if ( ! isset( $terms[ $term_slug ] ) ) {
Expand All @@ -352,7 +335,7 @@ public static function store_validation_errors( $validation_errors, $url ) {
$terms[ $term_slug ] = $term;
}

$stored_validation_errors[] = compact( 'term_slug', 'sources' );
$stored_validation_errors[] = compact( 'term_slug', 'data' );
}

$post_content = wp_json_encode( $stored_validation_errors );
Expand Down

0 comments on commit 3b484e8

Please sign in to comment.