-
Notifications
You must be signed in to change notification settings - Fork 31
Fix WPVIP feedback #893
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
Fix WPVIP feedback #893
Conversation
… that we store the report on uploads folder
DavidCramer
left a comment
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.
@pereirinha - It's all cool, but the logic in attachment_url_to_postid is not using the cache.
php/class-utils.php
Outdated
| if ( 0 === $attachment_id && empty( wp_cache_get( "postid_{$url}", 'cloudinary' ) ) ) { | ||
| $attachment_id = attachment_url_to_postid( $url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.attachment_url_to_postid_attachment_url_to_postid | ||
| wp_cache_set( "postid_{$url}", $attachment_id, 'cloudinary' ); | ||
| } |
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.
@pereirinha - You're not actually using the value from wp_cache_get. Perhaps this would be better placed when first defining the var: $attachment_id = wp_cache_get( "postid_{$url}", 'cloudinary' );
Then wrap all the logic in if ! empty
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.
Great catch. Ready for you to circle back ;)
DavidCramer
left a comment
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.
@pereirinha - Great stuff! Back to you.
This PR addresses some warnings seen on WPVIP.
Aside from minor spacing fixes and alike, it also introduces the following:
Utils::attachment_url_to_postid— a wrapper forwpcom_vip_attachment_url_to_postidor usewp_cacheto store this information. This should have a positive impact on performance;export_csvfor the CLI commands, which due to the VIP filesystem, could result in an impossibility of storing the export data;