-
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
Use a transient to cache the potentially slow "Pending URLs Count" query #3222
Conversation
@@ -82,6 +82,13 @@ class AMP_Validated_URL_Post_Type { | |||
*/ | |||
const VALIDATION_ERRORS_META_BOX = 'amp_validation_errors'; | |||
|
|||
/** | |||
* The transient key to use for caching the pending URLs count. |
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.
Instead of "pending" it would be more accurate to use "new" for the changes here. The URLs being queried are those with new accepted/rejected validation errors:
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_REJECTED_STATUS,
AMP_Validation_Error_Taxonomy::VALIDATION_ERROR_NEW_ACCEPTED_STATUS,
As opposed to ack rejected/accepted errors.
Using new
instead of pending
would be more consistent in regards to terminology.
But given the resulting containing element is pending-count
, I don't feel strongly about this.
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 don't feel strongly about this either, but I think the containing element should properly reflect this as well, then. Do you want me to rename both? I don't assume people provide custom styling for this, so BC is probably not an issue here...
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.
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.
Fixed in b887ee5
set_transient( static::NEW_VALIDATION_ERROR_URLS_COUNT_TRANSIENT, $new_validation_error_urls, DAY_IN_SECONDS ); | ||
} | ||
|
||
if ( 0 === $new_validation_error_urls ) { |
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.
FYI: The strict equality here caused a regression since integers stored in transients when no persistent object cache is used will get cast to strings. See #3478.
Extracts the pending URL count query into a separate method and then wraps usage of that method into a transient.
The key name is
amp_pending_urls_count
and the expiry time is set to 24h.Fixes #2736