Reordering fails with high volume of posts and WPML

Open
#19 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #18 by @rmpel — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php, wordpress
Domain
backend, databases

Research direction

No files or tests are named. Start by reproducing reordering with a high post volume and WPML, then trace the batch-processing and menu_order update path; done means moving a post a long distance preserves its new position and saving it does not revert the value.

Written by the indexing model from the issue text.

Description

help wanted needs:engineering type:enhancement

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.

Dominant language
PHP
Stars
157
Forks
24
Avg merge
12m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 10up/simple-page-ordering

All issues in 10up/simple-page-ordering

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.