Skip to content

Conversation

Vedant-Gandhi
Copy link
Contributor

Description

The aim of this PR is to disable the cache purge occurring when data is being imported in WordPress.

Type

  • New Feature

Reference Issue

#52

Testing

The code has been tested locally and is working as expected.

@Vedant-Gandhi Vedant-Gandhi self-assigned this Aug 8, 2024
Copy link
Member

@Pathan-Amaankhan Pathan-Amaankhan left a comment

Choose a reason for hiding this comment

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

Some PHPCS-related fixes.

* @return bool
*/
public function is_import_request() {
$import_query_var = sanitize_text_field( $_GET['import'] ?? '' );
Copy link
Member

Choose a reason for hiding this comment

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

  • phpcs: Generic.Formatting.MultipleStatementAlignment.NotSameWarning: Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

  • phpcs: WordPress.Security.NonceVerification.Recommended: Processing form data without nonce verification.

  • phpcs: WordPress.Security.ValidatedSanitizedInput.MissingUnslash: $_GET['import'] not unslashed before sanitization. Use wp_unslash() or similar

$import_query_var = sanitize_text_field( $_GET['import'] ?? '' );
$has_import_started = did_action( 'import_start' );

return (defined( 'WP_IMPORTING' ) && true === WP_IMPORTING) || 0 !== $has_import_started || ! empty( $import_query_var );
Copy link
Member

Choose a reason for hiding this comment

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

  • phpcs: Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen: Expected 1 space after open parenthesis; 0 found

  • phpcs: Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose: Expected 1 space before close parenthesis; 0 found

@@ -698,7 +697,11 @@ public function update_new_blog_options( $blog_id ) {
* @global object $nginx_purger
*/
public function purge_all() {


if( $this->is_import_request() ) {
Copy link
Member

Choose a reason for hiding this comment

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

phpcs: Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword: Expected 1 space after IF keyword; 0 found

Copy link
Member

@Pathan-Amaankhan Pathan-Amaankhan left a comment

Choose a reason for hiding this comment

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

LGTM

@Vedant-Gandhi Vedant-Gandhi merged commit 6931938 into develop Aug 12, 2024
3 checks passed
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.

2 participants