-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
The Issue with demo import with WP 6.1 #44946
Comments
cc @scruffian @carolinan @aristath you all in case any of you might be able to investigate this and come up with a possible solution for 6.1. This is definitely a point of concern for block themers for this release and it would be advantageous to have it solved sooner rather than later. |
Is it possible to reproduce this with a default theme as well? |
Same is happening with Twenty Twenty Two. I just installed the theme with WordPress 6.0 and choose the pink style variation. Exported the xml file. Installed 6.1 on the new installation, installed Twenty Twenty Two and imported xml file and same thing happens |
cc @WordPress/block-themers |
Hi @t-hamano, I think it's not the same issue as this one is related to importing demo content, xml file. And when u import .xml file, front-end is not showing the right styles (u can wait and wait) till u click on the edit site and later wait for few minutes 🤷♀️🤷♀️. This is what happend when I did checks. With 6.0 this is not happening. U immidiately see the right styles on the front when u import the demo file. But maybe the same issue is causing both things 🤷♀️🤷♀️ |
With 6.0, importing demo content with our Basti theme and default theme works perfectly and u can see styles immidiately applied on the front. In 6.1 it will not apply till u first click Edit Site 🤷♀️🤷♀️ |
Hi @anarieldesign, I think transients could be causing the issue. Commenting out line 431 of The name is dynamic, but it should be possible to clear the transient on the Hopefully there's a way to fix in core so the workaround isn't required. |
That's no longer working, maybe I was on an earlier 6.1 version. Not sure why it worked that time but I'll keep looking into it. |
@ajlende @andrewserong do you think this could have been broken by some of the changes to the caching recently? |
cc/ @oandregal @c4rl0sbr4v0 in case this rings a bell since it might be related to WordPress/wordpress-develop#3418. Note #44946 (comment):
but also #44946 (comment):
|
The note in the PR description that it takes a few minutes for changes to appear points to it being potentially related to transients rather than the change in WordPress/wordpress-develop#3418 (which should be refreshed on each page load?) Looking through recent commit history in |
It's not just that it takes few minutes to appear. When u import the .xml file and u stay on the front-end it will not show the right style till u first click on the edit site. And then u need to wait for few minutes @andrewserong |
Changing to a transit might have effects this. Transient data, even if you don't have object caching enabled. Global styles are not correctly cache invalidated. Caches are not deleted on global style imports. We may want to remove the transient caching all together and relay on the caching found in WP_Query. |
Reading this looks like we should invalidate any style caching when importing. Also it does not look like https://github.com/WordPress/wordpress-develop/pull/2414/files is causing this because the values were cached before but in a different way. Speculation from reading code, not tested. |
When testing the same thing with 6.0 this is not happening, importing content works all good and it shows immidiately on the front. Maybe this can help to see what has been changed in 6.1 that is causing this issue @draganescu |
Did you test with object caching enabled? |
The issue here is there is no cache invalidation. You dont see this issue on dev environment as object caching is not enabled. Using a transient means it is cached for sites without object caching. This would have always been an issue. I am CC @peterwilsoncc has he has some context here. I think the easier fix would be removing this caching all together and relay on WP_Query caching upstream. |
This is my inclination given WP 6.1 has the lower level caching. It saves double handing and a duplicate cache entry/invalidation. Just so I am clear, the issue is with the database query rather than the optimisation of theme.json -- is that correct? |
I attempted to use the lower level caching in WordPress/wordpress-develop#3517 but without success. In the loop to test caching, I am getting zero results for the query (thus returning an empty array). I am unsure if I have discovered an existing bug with the WP_Query arguments or if it's something I have introduced in my PR. Anyone with the required permissions should feel free to push to my branch if you can see where I've done something silly. |
I've updated WordPress/wordpress-develop#3517 and it is now ready for review. The test for
I'm unclear whether the intent is to create styles for logged out users, I have assumed not as the permissions are not set correctly. Could I please get a review of the PR and some tests on the branch? |
This looks good to me for fixing up the caching logic! Testing out that PR revealed one other piece of the puzzle for me. On a site that already has a global style custom post entry for the currently active theme, when we run the importer, if the post id is the same, then the importer sees that there's already a post, and doesn't create a new post for the imported custom global styles data. For example, here is the output from running the importer on a site that already has an entry in the global styles custom post type for the current theme: Note that last line: I'm not too sure what the correct behaviour here is for the importer logic, as it's outside of my experience so far (I haven't touched the importer logic, and am also not all that familiar with the global styles custom post type logic, so please take my observations here with a grain of salt 🙂). However, it sounds like something will likely need to change in how importers handle importing the This might need some input from @jorgefilipecosta, @oandregal or someone who has deeper knowledge of the expected behaviour of the global styles custom post type, and how importing over the existing settings should work. |
I've created WP#56901 for tracking the commit to WordPress-Develop. @anarieldesign are you able to link your WordPress.org account to GitHub so you can be included in the props for the ticket? You can do so on your profile https://profiles.wordpress.org/me I'll keep this ticket open for tracking the changes for the Gutenberg repository. |
Thank u, I connected it now 🙏 @peterwilsoncc |
Looked at WordPress/wordpress-develop#3517 (comment) from a performance point of view and I have seen no performance penalties from removing the caching from the method. I haven't seen any data provided by the PRs that introduced the caching either (#36584 and WordPress/wordpress-develop#2414 ). A personal takeaway is that any PR that claims a performance improvement should provide data for a test case that is actually improved. |
My understanding is that the importer works the way it does to prevent an unexpected data loss. As it works now, styles work the same as any other post type. If the user wants the styles from the XML and they have some data, they can delete the existing and import. Changing the behavior to always overwrite means that users can lose changes to styles if they import (they need to be aware that styles also come in that XML and whether the source they import from has user changes to styles). |
Great point, it's easy to overlook things like this when focusing on a single use case (the user who does want to overwrite). I agree, that for the user who wishes to overwrite their own settings, it's up to them to clear out their user styles first. Sounds like there's nothing that needs to change from the importers side, then. Thanks for confirming! |
To be clear, fallbacking to WordPress core's I think removing this cache for 6.1 is a quick work around. But a longer term solution is to cache global styles forever and then correctly cache invalid when a global style post is created/update/delete in the database. Using a last changed date for just global styles as the salt for the cache key might work. But this would need unit tests etc and does seems likely to complete in time we have left in WP 6.1 release cycle. |
It is also worth noting that |
Do u have any workaround in case this will not be fixed with 6.1? What we can do as a theme authors? We already sell our block theme with demo imports and it worked perfectly with 6.0 and now is a big mess. We can't tell users, oh please first click on edit site, exit and then wait for 10min or something 🤷♀️🤷♀️. Thank u for all your hard work 🙏 |
@anarieldesign it should be possible to add a hook after import to clear the transients and global styles. I haven't tested lately but if this approach works for you then I'd be happy to assist further: add_action( 'merlin_after_all_import', 'delete_existing_global_styles', 11 );
/**
* Deletes global style transients after importing demo content.
*
* @since 1.0.0
*
* @return void
*/
function delete_existing_global_styles() : void {
$theme = get_stylesheet();
delete_transient( 'gutenberg_global_styles_' . $theme );
// Force delete existing custom styles.
$custom_styles = get_posts( [
'post_type' => [ 'revision', 'wp_global_styles' ],
'post_title' => 'Custom Styles',
] );
foreach ( $custom_styles as $custom_style ) {
wp_delete_post( $custom_style->ID, true );
}
} |
Thank u for sharing this @seothemes 🙏. I'll test this out during the weekend and will let u know 🙏 |
@seothemes In order to make sure you receive props for your work on this PR in the 6.1 release of WordPress, are you able to link your GitHub account to your WordPress.org account? |
Update: Fixes were merged into WP Core's |
Thank you,I'll check it tomorrow and let u know if I notice anything strange 👌🙏 |
@dream-encode thanks for the tip, I have linked my .org account blockify - although I didn't really help much with this one. |
@seothemes Thanks! You'll now be credited in the final 6.1 release! |
Thank you everyone for the help and for the fixes 👍 |
I guess this has been solved, so we can close the issue. Feel free to reopen if needed! |
Description
When importing demo content using WP 6.1 styles are not imported correctly although the same works fine in WP 6.0.2.
Imported content displays the theme's default colors and styling instead of the styling set for that particular demo. However, in the "Site Editor" styles are correctly displayed. Sometimes when I exit the Site Editor the styles are then correctly displayed in the front end as well, but sometimes it takes a few tries.
This issue happens with the WordPress default importer as well as our theme's built-in import system.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Default WordPress Importer Video:
basti-default.mp4
Basti Demo Importer Video:
basti-importer.mp4
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Same is happening with Twenty Twenty Two. I just installed the theme with WordPress 6.0 and choose the pink style variation. Exported the xml file. Installed 6.1 on the new installation, installed Twenty Twenty Two and imported xml file and same thing happens 🤷♀️
The text was updated successfully, but these errors were encountered: