-
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
Validate URL if validation data does not exist while generating support data. #6718
Conversation
71d2bdf
to
fb5bb27
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6718 +/- ##
=============================================
+ Coverage 77.12% 77.14% +0.01%
- Complexity 6553 6565 +12
=============================================
Files 262 262
Lines 20884 20929 +45
=============================================
+ Hits 16107 16145 +38
- Misses 4777 4784 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Plugin builds for cf8d5f2 are ready 🛎️!
|
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.
I've reviewed and tested this PR locally. Everything seems to be working as expected for me.
I left some feedback on the frontend part and briefly browsed the backend code. @bartoszgadomski would you be able to do a more thorough code review (mainly the backend part)?
While testing this PR. Found a bug that when there are more than 100 This can be fixed quickly by adding However, the problem with the first approach is it might skip the posts that have a CSS budget of more than 100%. |
Add notice in AMP Support page if there is not AMP error
05c4e1c
to
aab5aee
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.
Thank you for addressing the code review feedback. It looks good to me now 👍
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.
Looks good to me 👍
…support-request * 'develop' of github.com:ampproject/amp-wp: (39 commits) Harden is_needed check to include has_cap Fix another usage of Encoding Sort imports for impacted files Add noopener to external link Update to amp-toolbox 0.9.1 Open validated URLs in new window to prevent accidental loss Show URLs with validation issues to non-technical users as well Cover case when Gutenberg is not active with E2E tests Do not scan site for network activated plugins Enqueue missing `wp-components` CSS dependency Ensure timeout has been set before trying to clear it Update E2E tests Improve plugin activation post-site-scan message copy Ensure demo plugin is deactivated before running tests Update plugin activation message if validation errors are found Update E2E tests to reflect recent changes Always pass 2 arguments to `visitAdminPage()` Rename `AdminNotice` component to `AmpAdminNotice` Cleanly skip test if dependency is missing Apply notice text update suggestions from code review ...
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.
I'm testing this but it's not working for me. I'm getting an infinite series of HTTP requests that end in 500 errors:
error.mov
The console shows:
Error log has:
[03-Dec-2021 03:13:54 UTC] PHP Fatal error: Uncaught Error: Call to undefined function AmpProject\AmpWP\Support\post_exists() in /app/public/content/plugins/amp/src/Support/SupportData.php:695
Stack trace:
#0 /app/public/content/plugins/amp/src/Support/SupportData.php(200): AmpProject\AmpWP\Support\SupportData->get_amp_urls()
#1 /app/public/content/plugins/amp/src/Support/SupportData.php(159): AmpProject\AmpWP\Support\SupportData->get_data()
#2 /app/public/content/plugins/amp/src/Support/SupportRESTController.php(107): AmpProject\AmpWP\Support\SupportData->send_data()
#3 /app/public/core-dev/src/wp-includes/rest-api/class-wp-rest-server.php(1141): AmpProject\AmpWP\Support\SupportRESTController->callback(Object(WP_REST_Request))
#4 /app/public/core-dev/src/wp-includes/rest-api/class-wp-rest-server.php(988): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/amp/v1/send-di...', Array, NULL)
#5 /app/public/core-dev/src/wp-includes/rest-api/class-wp-rest-server.php(414): WP_REST_Server->dispatch(Object(WP_REST_Request))
#6 /app/public/core-dev/s in /app/public/content/plugins/amp/src/Support/SupportData.php on line 695
```
In the case of an error, it shouldn't automatically try to re-send. It should prompt the user to push the submit button again.
Use AMP_Validated_URL_Post_Type::get_invalid_url_post() instead of post_exists()
I have updated it. And now in case of error, it will show an error message to the user. Regarding error. While checking further found that Now instead of using |
…support-request * 'develop' of github.com:ampproject/amp-wp: Clear timeout correctly Simplify the E2E test Simplify logic for ensuring consistent units Propagate more styles AMP-valid dimensions to AMP element Add tests for deriving width/height from styles Propagate width/height styles as width/height attributes when setting layout
register_rest_route( | ||
$this->namespace, | ||
'/get-diagnostic', | ||
[ | ||
[ | ||
'methods' => WP_REST_Server::READABLE, | ||
'args' => [], | ||
'permission_callback' => [ $this, 'permission_callback' ], | ||
'callback' => [ $this, 'get_item' ], | ||
], | ||
] | ||
); | ||
|
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.
This endpoint isn't being used anywhere, and it's not validating the args
. So I think it should be removed.
Partially revert "Update function docs." This reverts commit 262371d.
I'm still getting an error when submitting this, but this time it seems to be an issue with the insights server. It's responding with: {
"status": "fail",
"data": [
{
"message": "required validation failed on plugins.0.version",
"field": "plugins.0.version",
"validation": "required"
},
{
"message": "required validation failed on plugins.5.version",
"field": "plugins.5.version",
"validation": "required"
},
{
"message": "required validation failed on plugins.6.version",
"field": "plugins.6.version",
"validation": "required"
}
]
} It is because I have active plugins which do not have a Filed as https://github.com/rtCamp/px-wp-insights/issues/186. |
'posts_per_page' => 1, | ||
'post_status' => 'publish', | ||
'meta_key' => AMP_Validated_URL_Post_Type::VALIDATED_ENVIRONMENT_POST_META_KEY, | ||
'meta_value' => maybe_serialize( AMP_Validated_URL_Post_Type::get_validated_environment() ), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value |
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.
This is a clever way to query for non-stale results.
} | ||
|
||
$amp_invalid_url = [ | ||
'url' => $amp_validated_post->post_title, |
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.
This and other instances in the file could use \AMP_Validated_URL_Post_Type::get_url_from_post()
.
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.
Updated in new PR #6764
'post_status' => 'publish', | ||
'meta_key' => AMP_Validated_URL_Post_Type::VALIDATED_ENVIRONMENT_POST_META_KEY, | ||
'meta_value' => maybe_serialize( AMP_Validated_URL_Post_Type::get_validated_environment() ), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value | ||
's' => 'term_slug', |
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.
Why search for term_slug
? Just something that exists in the 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.
Added term_slug
as a search query string to make sure any data we fetch has an error and is not empty.
term_slug
will always be available in post content for amp_invalidated_url
posts that have errors.
if ( ! empty( $source['sources'] ) && is_array( $source['sources'] ) ) { | ||
foreach ( $source['sources'] as $index => $inner_source ) { | ||
$source['sources'][ $index ] = self::normalize_error_source( $inner_source ); | ||
} | ||
|
||
$source['sources'] = array_values( array_filter( $source['sources'] ) ); | ||
} |
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.
This was added in 9c8ef66 to add normalization of nested sources?
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, I have added to normalize nested sources.
Summary
Fixes #6707
This PR adds changes to support request flow. With new changes, while preparing support data if validation data for the requested URL doesn't found it will validate and store the data for the URL (which previously doesn't happen)
Also, Added appropriate messages when there is no AMP related error information.
Checklist