#36429 closed defect (bug) (fixed)
Twenty Eleven Ephemera widget fails to prevent caching in Customizer preview
Reported by: | westonruter | Owned by: | karmatosed |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 3.2 |
Component: | Bundled Theme | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
Changes to Twenty Eleven's Ephemera widget are currently getting cached when being changes in the Customizer Preview. This is specifically a problem when an external persistent object cache is used, since the cache gets dumped with each request otherwise.
A change somewhat like this is needed:
-
src/wp-content/themes/twentyeleven/inc/widgets.php
class Twenty_Eleven_Ephemera_Widget extends WP_Widget { 56 56 if ( ! isset( $args['widget_id'] ) ) 57 57 $args['widget_id'] = null; 58 58 59 if ( isset( $cache[ $args['widget_id'] ] ) ) {59 if ( ! is_customize_preview() && isset( $cache[ $args['widget_id'] ] ) ) { 60 60 echo $cache[ $args['widget_id'] ]; 61 61 return; 62 62 } … … class Twenty_Eleven_Ephemera_Widget extends WP_Widget { 132 132 endif; 133 133 134 134 $cache[ $args['widget_id'] ] = ob_get_flush(); 135 wp_cache_set( 'widget_twentyeleven_ephemera', $cache, 'widget' ); 135 if ( ! is_customize_preview() ) { 136 wp_cache_set( 'widget_twentyeleven_ephemera', $cache, 'widget' ); 137 } 136 138 } 137 139 138 140 /**
Attachments (2)
Change History (11)
#4
@
9 years ago
- Keywords needs-patch removed
New contributor here, so hopefully I'm doing this right.
I was able to duplicate this issue in the twentyeleven theme by installing W3 Total Cache and toggling on all caching types. After activating the cache, I went to edit the title of the Ephemera widget in the Customizer. The new title did not show up in the preview pane.
After the changes to widgets.php, I went back into the Customizer and was able to edit and view the new title.
#5
@
9 years ago
Hi @anneschmidt and welcome. Unfortunately, I am unable to get your patch working. Can you please follow the instructions here for creating a patch: https://make.wordpress.org/core/handbook/tutorials/trac/submitting-a-patch/. I do notice also, you have a few new lines that @westonruter's suggestion doesn't. It would be a good idea to tidy those.
If you are having issues creating the patch, just let us know and I can commit your suggestion still in your name. Thanks so much for contributing.
added is_customize_preview()