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

Reordering fails with high volume of posts and WPML #19

Open
rmpel opened this issue Apr 13, 2018 · 2 comments
Open

Reordering fails with high volume of posts and WPML #19

rmpel opened this issue Apr 13, 2018 · 2 comments
Labels
help wanted needs:engineering This requires engineering to resolve. type:enhancement New feature or request.

Comments

@rmpel
Copy link

rmpel commented Apr 13, 2018

In a situation with more posts than the batch processing does in one go and the multilingual plugin WPML, reordering fails when the new position is more than a few posts away from the original position

In our situation, the post was at menu_order 64 and needed to go to 10. I dragged the post, the menu_order reverted to 64 (no change)
when editing the post en using the menu_order meta box in the right column, change the value 64 to 10, and hit "update post", the value reverted to 64.
when editing the value directly in the database, from 64 to 10, re-opening the edit pane of the post, the value stated 10 and the post was at the correct position. When just hitting "update post" without changing any data on the edit page, the value reverted to 64.

I then proceeded to debugging the plugin, using error_log lines at specific points in the page and noticed that the reordering kept on going even after closing the browser, which made me realise; the reordering is going on still and being very slow.

I have built re-order algorithms lots of times in my long career and applied a series of database queries I thought up years ago;

multiply all order values by 2, even numbers are "current" positions
change the position of the dragged item to an odd number between the two items the item needs to go
renumber all posts starting at 1.
done.

@helen
Copy link
Contributor

helen commented May 2, 2018

Thanks for opening an issue for discussion @rmpel, and apologies for not getting back around to it sooner. @jakemgold and I have definitely talked a few times about moving to direct/batch queries - including shortly before you opened your PR, actually. The part we always seem to get stuck at is what hooks to trigger that would normally be called with wp_update_post(), if any. It's entirely possible we decide to just leave it as only calling the hooks for the post that was moved or even none at all, we just need to make sure it's been thoroughly considered especially for common use cases/plugins.

Do you have any sense of what exactly is going so slowly and what WPML is doing that causes it? It sounds rather like something is looping back and re-applying the ordering based on your description, since the plugin only triggers the reordering when using drag and drop. I've tested with a couple thousand pages and it's been a little slow on first reorder but not to the extent you're describing.

As for the approach itself, it may be good for us to figure out some controlled tests (automated or not) to compare speeds so we know for sure we are moving in the right direction. So for instance, a fresh ordering where none of the pages have a menu order assigned yet, moving 5 spots, moving 20 spots, moving a child page, and so forth.

@rmpel
Copy link
Author

rmpel commented May 2, 2018 via email

@jeffpaul jeffpaul added this to the 2.4.0 milestone May 30, 2019
@adamsilverstein adamsilverstein self-assigned this Oct 9, 2019
@jeffpaul jeffpaul modified the milestones: 2.3.3, Future Release Mar 19, 2020
@jeffpaul jeffpaul linked a pull request Jun 13, 2022 that will close this issue
@jeffpaul jeffpaul added type:enhancement New feature or request. help wanted needs:engineering This requires engineering to resolve. labels Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted needs:engineering This requires engineering to resolve. type:enhancement New feature or request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants