Skip to content

Conversation

@pereirinha
Copy link
Contributor

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 for wpcom_vip_attachment_url_to_postid or use wp_cache to store this information. This should have a positive impact on performance;
  • fixes on export_csv for the CLI commands, which due to the VIP filesystem, could result in an impossibility of storing the export data;
  • Increases the sensibility of the PHPCS so that we can sooner spot these issues;

@pereirinha pereirinha changed the base branch from master to develop July 31, 2023 13:58
@pereirinha pereirinha requested a review from DavidCramer July 31, 2023 13:58
Copy link
Contributor

@DavidCramer DavidCramer left a 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.

Comment on lines 931 to 934
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' );
}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidCramer

Great catch. Ready for you to circle back ;)

@pereirinha pereirinha requested a review from DavidCramer August 22, 2023 08:27
Copy link
Contributor

@DavidCramer DavidCramer left a 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.

@pereirinha pereirinha merged commit 6f235bc into develop Aug 22, 2023
@pereirinha pereirinha deleted the fix/vip-feedback branch August 23, 2023 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants