Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#36429 closed defect (bug) (fixed)

Twenty Eleven Ephemera widget fails to prevent caching in Customizer preview

Reported by: westonruter's profile westonruter Owned by: karmatosed's profile 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 { 
    5656                if ( ! isset( $args['widget_id'] ) )
    5757                        $args['widget_id'] = null;
    5858
    59                 if ( isset( $cache[ $args['widget_id'] ] ) ) {
     59                if ( ! is_customize_preview() && isset( $cache[ $args['widget_id'] ] ) ) {
    6060                        echo $cache[ $args['widget_id'] ];
    6161                        return;
    6262                }
    class Twenty_Eleven_Ephemera_Widget extends WP_Widget { 
    132132                endif;
    133133
    134134                $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                }
    136138        }
    137139
    138140        /**

Attachments (2)

widgets.diff (714 bytes) - added by anneschmidt 9 years ago.
added is_customize_preview()
36429.patch (702 bytes) - added by anneschmidt 9 years ago.

Download all attachments as: .zip

Change History (11)

#1 @westonruter
9 years ago

  • Keywords good-first-bug needs-patch added

#2 @karmatosed
9 years ago

  • Milestone changed from Future Release to 4.6

#3 @karmatosed
9 years ago

  • Owner set to karmatosed
  • Status changed from new to assigned

@anneschmidt
9 years ago

added is_customize_preview()

#4 @anneschmidt
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 @karmatosed
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.

#6 @anneschmidt
9 years ago

Hi @karmatosed - thanks so much for your feedback and help. I'm attaching a second patch - can you let me know if this one works for you? Thanks!

@anneschmidt
9 years ago

#7 @ocean90
9 years ago

  • Keywords has-patch added

#8 @karmatosed
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 37590:

Twenty Elevent Ephemera widget fix for caching in Customizer preview.
Fixes #36429. Props anneschmidt, westonruter.

#9 @karmatosed
9 years ago

@anneschmidt just to let you know, I couldn't get your patch working. However, I took the work you'd done and made a fix for that. Thanks for sending your patch in and if this is your first props - congratulations!

Note: See TracTickets for help on using tickets.