You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Changingtitle of Pattern file (in /patterns dir) is not reflected in the Editor UI - that shows the previous state #64173
NOTE: the only workaround I found to let the Editor show the current pattern title is to change theme and then switch back to twentytwentyfour.
I tested 2 block themes , so it is not related to twentytwentyfour
Step-by-step reproduction instructions
Install a fresh TwentyTwentyFour theme
Go to Apperence > Editor > Patterns > Featured (category)
Check that the name of the "FAQ" pattern is "FAQ"
Go to /patterns/text-faq and update like so
<?php
/**
- * Title: FAQ+ * Title: FAQ Hello
* Slug: twentytwentyfour/text-faq
* Categories: text, about, featured
* Keywords: faq, about, frequently asked
* Viewport width: 1400
* Description: A FAQ section with a large FAQ heading and list of toggle questions and answers.
*/
?>
Reload the page of step 2
Check that the name of the "FAQ" pattern is still "FAQ" and not expected "FAQ Hello"
Screenshots, screen recording, code snippet
No response
Environment info
WP 6.6.1
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Hi @tresorama
I was going through your issue, I was able to replicate till Step 3..
But I'm unable to find where this text-faq pattern is in code, can you please help me with the same
Thanks
changed the title [-]Bug: Change `title` of `Pattern` file (in `/patterns` dir) is not reflected in the Editor UI - that shows the previous state[/-][+]Bug: Changing`title` of `Pattern` file (in `/patterns` dir) is not reflected in the Editor UI - that shows the previous state[/+]on Aug 1, 2024
I think this issue is related to patterns being cached.
If you want to see changes to your theme patterns immediately, defining WP_DEVELOPMENT_MODE may help. Try defining one of the following in wp-config.php:
* dev create a block theme for a client on day 1 and deploy it
* on day 2 developer update some Patterns inside `/patterns` of the theme and deploy the theme to the production site
@tresorama if the developer also increases the theme version, this should refresh the cache and the updated pattern will display as expected.
* dev create a block theme for a client on day 1 and deploy it
* on day 2 developer update some Patterns inside `/patterns` of the theme and deploy the theme to the production site
@tresorama if the developer also increases the theme version, this should refresh the cache and the updated pattern will display as expected.
@Andrew-Starr Thanks for this! This sounds like an appropriate solution for production environments.
Although I would expect, that there must be also a way to clear the cache from the backend.
This does not seem to work for me. Is this actual code or just what would be ideal? The only thing I've found that works is going into the database and deleting the transient option. Changing theme version number, supposedly deleting transients with WP-Optimize, or using this code do not work. When I try to set WP_DEVELOPMENT_MODE I get an error saying it's already been set, though I can't find anywhere else it's set other than where I put it in wp-config.php.
I have no response but I'll open again
Edit : I cannot re open it in mobile app. We'll do it later. Or maybe a maintainer can do it in the meanwhile ...
This does not seem to work for me. Is this actual code or just what would be ideal? The only thing I've found that works is going into the database and deleting the transient option. Changing theme version number, supposedly deleting transients with WP-Optimize, or using this code do not work. When I try to set WP_DEVELOPMENT_MODE I get an error saying it's already been set, though I can't find anywhere else it's set other than where I put it in wp-config.php.
This is how I use it and it works by making this GET request: /wp-admin/?purge-theme-cache
add_action( 'admin_init', 'boom_purge_themes_cache' );
function boom_purge_themes_cache() {
if ( isset( $_GET['purge-theme-cache'] ) ) {
$theme = wp_get_theme();
$theme->delete_pattern_cache();
}
}
This does not seem to work for me. Is this actual code or just what would be ideal?
This is the code that actually works.
When I try to set WP_DEVELOPMENT_MODE I get an error saying it's already been set, though I can't find anywhere else it's set other than where I put it in wp-config.php.
You cannot declare a constant twice. If the WP_DEVELOPMENT_MODE constant already exists in the wp-config.php file, change its value.
Another easy way to clear the pattern cache is to switch the active theme to a different one. This is because the switch_theme() function contains a process for deleting patterns cache:
This is how I use it and it works by making this GET request: /wp-admin/?purge-theme-cache
Thanks so much -- this works great. @t-hamano thank you for your reply as well. Although I still can't figure out where WP_DEVELOPMENT_MODE is already being set, I'm happy with the delete_pattern_cache() solution.
Activity
tresorama commentedon Aug 1, 2024
It happens also with
Categoriesproperty other thanTitleRishit30G commentedon Aug 1, 2024
Hi @tresorama
I was going through your issue, I was able to replicate till Step 3..
But I'm unable to find where this
text-faqpattern is in code, can you please help me with the sameThanks
tresorama commentedon Aug 1, 2024
Yep.
In
wp-content/themes/twentytwentyfour/patterns/text-faq.php[-]Bug: Change `title` of `Pattern` file (in `/patterns` dir) is not reflected in the Editor UI - that shows the previous state[/-][+]Bug: Changing`title` of `Pattern` file (in `/patterns` dir) is not reflected in the Editor UI - that shows the previous state[/+]t-hamano commentedon Aug 2, 2024
Thanks for the report.
I think this issue is related to patterns being cached.
If you want to see changes to your theme patterns immediately, defining WP_DEVELOPMENT_MODE may help. Try defining one of the following in
wp-config.php:tresorama commentedon Aug 2, 2024
Thanks @t-hamano .
It works if I do what you suggested. But now I have other questions 😎
Question 1
What happens if
/patternsof the theme and deploy the theme to the production siteThe client will see old or new metadata of patterns ?? Assuming the in production the
WP_DEVELOPMENT_MODEconstant isfalseQuestion 2
Also, which is the reason to caching these kind of stuff ? It is for IO performance?
Thanks in advance
t-hamano commentedon Aug 3, 2024
Yes, looking at the source code, the pattern should be cached for 1800 seconds (30 minutes).
https://github.com/t-hamano/wordpress-develop/blob/a799101e46ef0a042814c189a6331c23a52a100c/src/wp-includes/class-wp-theme.php#L236
Also, which is the reason to caching these kind of stuff ? It is for IO performance?
Probably so, and the comments in the core changeset below and the associated linked ticket may give you some idea why.
Changeset 58025 - Themes: Cache block theme patterns in a transient.
tresorama commentedon Aug 3, 2024
Thanks @t-hamano for this detailed response.
Will take a look into this, along with this article that speak about
WP_DEVELOPMENT_MODEintroduction.https://make.wordpress.org/core/2023/07/14/configuring-development-mode-in-6-3/
Closing this issue.
Andrew-Starr commentedon Aug 5, 2024
@tresorama if the developer also increases the theme version, this should refresh the cache and the updated pattern will display as expected.
tresorama commentedon Aug 5, 2024
It makes sense!
Thanks for clarification @Andrew-Starr
margarita-boomCodes commentedon Sep 18, 2024
@Andrew-Starr Thanks for this! This sounds like an appropriate solution for production environments.
Although I would expect, that there must be also a way to clear the cache from the backend.
t-hamano commentedon Sep 18, 2024
@margarita-boomCodes
We should be able to clear the pattern cache with the following code:
nabrown commentedon Dec 18, 2024
This does not seem to work for me. Is this actual code or just what would be ideal? The only thing I've found that works is going into the database and deleting the transient option. Changing theme version number, supposedly deleting transients with WP-Optimize, or using this code do not work. When I try to set
WP_DEVELOPMENT_MODEI get an error saying it's already been set, though I can't find anywhere else it's set other than where I put it inwp-config.php.tresorama commentedon Dec 18, 2024
I have no response but I'll open again
Edit : I cannot re open it in mobile app. We'll do it later. Or maybe a maintainer can do it in the meanwhile ...
margarita-boomCodes commentedon Dec 18, 2024
This is how I use it and it works by making this GET request:
/wp-admin/?purge-theme-cachet-hamano commentedon Dec 19, 2024
This is the code that actually works.
You cannot declare a constant twice. If the
WP_DEVELOPMENT_MODEconstant already exists in thewp-config.phpfile, change its value.Another easy way to clear the pattern cache is to switch the active theme to a different one. This is because the
switch_theme()function contains a process for deleting patterns cache:https://github.com/t-hamano/wordpress-develop/blob/a27e6a8ecd5279a45e47ef88d048643740d07b5a/src/wp-includes/theme.php#L853-L857
nabrown commentedon Dec 19, 2024
Thanks so much -- this works great.
@t-hamano thank you for your reply as well. Although I still can't figure out where
WP_DEVELOPMENT_MODEis already being set, I'm happy with thedelete_pattern_cache()solution.