ColorlibHQ / simple-custom-post-order

Order posts(posts, any custom post types) using a Drag and Drop Sortable JavaScript. Configuration is unnecessary.
http://wordpress.org/plugins/simple-custom-post-order/
GNU General Public License v3.0
31 stars 20 forks source link

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

Open beatricelucaci opened 2 years ago

beatricelucaci commented 2 years ago

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 ) ) );

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

marian-kadanka commented 2 years ago

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

danimalweb commented 1 year ago

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