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

Object cache invalidation missing on drag’n’drop reorder #115

Open
beatricelucaci opened this issue Nov 8, 2021 · 2 comments
Open

Comments

@beatricelucaci
Copy link

When dragging and dropping posts using SCPOrder to reorder them, the menu_order field does get updated in the database. However the object cache does not seem to be invalidated as it should. The easiest way to realize that is to enable object cache and comparing the menu_order values as presented in the admin interface with the values actually used (as also visible through API usage or examination of the wp_posts table of the database).

Please compare this behavior with when editing the menu_order field using Edit or Quick Edit or WP Core. Updating the field that way will not cause caching issues. A reasonable expectation would be that the usability of sorting using SCPOrder should be comparable with that of WP Core.

This diff against current svn trunk made the issue go away for us. Cleaner patches might be possible, but I do not really know this code base.

Index: simple-custom-post-order.php

--- simple-custom-post-order.php (revision 2625439)
+++ simple-custom-post-order.php (working copy)
@@ -338,6 +338,7 @@
foreach ( $data as $key => $values ) {
foreach ( $values as $position => $id ) {
$wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_order_arr[ $position ] ), array( 'ID' => intval( $id ) ) );

  •                           clean_post_cache( $id );
                      }
              }
    

https://wordpress.org/support/topic/object-cache-invalidation-missing-on-dragndrop-reorder/

@marian-kadanka
Copy link

marian-kadanka commented Aug 14, 2022

Nor is the term cache purged after drag and drop, in case of reordering terms in taxonomy.

@danimalweb
Copy link

Is it possible to get a fix for this in the next release?

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

No branches or pull requests

3 participants