Skip to content
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 WPML clearing all languages cache #6263

Merged
merged 6 commits into from
Nov 20, 2023

Conversation

wordpressfan
Copy link
Contributor

@wordpressfan wordpressfan commented Nov 7, 2023

Description

Here we introduced a new filter that runs after clearing cache and used in preload as in the issue's grooming.

Fixes #6214

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).

Is the solution different from the one proposed during the grooming?

Exactly as it's groomed.

Checklists

Generic development checklist

  • My code follows the style guidelines of this project, with adapted comments and without new warnings.
  • I have added unit and integration tests that prove my fix is effective or that my feature works.
  • The CI passes locally with my changes (including unit tests, integration tests, linter).
  • Any dependent changes have been merged and published in downstream modules.
  • If applicable, I have made corresponding changes to the documentation. Provide a link to the documentation.

Test summary

  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I validated all Acceptance Criteria of the related issues. (If applicable, provide proof).
  • I validated all test plan the QA Review asked me to.

If not, detail what you could not test.

Please describe any additional tests you performed.

@wordpressfan wordpressfan self-assigned this Nov 7, 2023
@wordpressfan wordpressfan marked this pull request as ready for review November 10, 2023 11:15
Copy link
Contributor

@nicomollet nicomollet left a comment

Choose a reason for hiding this comment

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

The doc to fix?

inc/functions/files.php Outdated Show resolved Hide resolved
Copy link
Contributor

@Tabrisrp Tabrisrp left a comment

Choose a reason for hiding this comment

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

Did you check if there was other instances of callbacks on after_rocket_clean_domain that could be replaced to optimize this?

@wordpressfan
Copy link
Contributor Author

Did you check if there was other instances of callbacks on after_rocket_clean_domain that could be replaced to optimize this?

That's a good point, I saw some cases but I wasn't sure if we need to do this here and overload this PR or not, but I believe u r correct, let me check them and see.

@Mai-Saad Mai-Saad self-requested a review November 17, 2023 12:21
@Mai-Saad
Copy link
Contributor

Mai-Saad commented Nov 20, 2023

@wordpressfan Thanks for the PR. A request is done once now when changing settings, full cache clear from admin, clearing used CSS, changing permalinks (assuming that all will trigger this function

set_transient( 'wpr_preload_running', true );
). However, when we switch theme can see many calls to the same function, can you please check 🙏

@wordpressfan
Copy link
Contributor Author

wordpressfan commented Nov 20, 2023

When we switch theme we are hooking rocket_clean_domain callback with three different hooks in the following locations:

First location:

add_action( 'update_option_theme_mods_' . get_option( 'stylesheet' ), 'rocket_clean_domain' ); // When location of a menu is updated.

Second location:

add_action( 'update_option_sidebars_widgets', 'rocket_clean_domain' ); // When you change the order of widgets.

Third and main location:

add_action( 'switch_theme', 'rocket_clean_domain' ); // When user change theme.

I believe this is another issue.

cc @piotrbak

@piotrbak
Copy link
Contributor

@Mai-Saad @wordpressfan Yes, this is different issue. Let's go with separate issue for this one

@Mai-Saad
Copy link
Contributor

Working as expected then. (Note, the behavior when switch theme is the same even without WPML)

@Mai-Saad Mai-Saad added this pull request to the merge queue Nov 20, 2023
Merged via the queue into develop with commit 4c024ba Nov 20, 2023
8 checks passed
@Mai-Saad Mai-Saad deleted the fix/6214-wpml-clear-all-languages-cache branch November 20, 2023 12:20
@wordpressfan
Copy link
Contributor Author

The other issue is created here: #6276

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.

Avoid clearing cache once per language
6 participants