Finally, some code in time for the deadline.
That patch, once applied, should prompt you for a database upgrade, automatically populate the tree with the necessary data, and use some new methods to take advantage of MPTT to display the category list (full and paged). If there are any bugs, please let me know, as I’ve only been able to test it under the conditions of my controlled environment (XAMPP for Linux).
For large numbers of categories (several hundred to a few thousand), I see a fairly consistent speedup of 8-10% with my set-up. Currently, it only works for displaying the data in the order it is stored in. Ryan and I decided that the best way to do that would be in order by name. Oddly enough, it would seem that using PHP5’s strcmp() to do the ordering produces a slightly different order than MySQL’s ORDER BY. Namely, you get the natural number ordering that Windows was so proud of a few years back (i.e. 80 comes before 100).
It still needs some polish, for instance the MPTT_Walker class still uses the old paged_walk() method, but since this seems to be used for comments only, I’m waiting until I handle those. Other things like that are scattered around. Also I still need to convert cat_rows() to be iterative rather than recursive, like I did for walk(). Other than that, the main portion of code for categories is done.
Again, feel free to test it out and let me know how it goes!
Per our discussion, double check your move_subtree() function. I haven’t tried it, but if you’ve node A and B, adjacent and both with children, ordered A, B; and switch the two so they’re ordered as B, A; or if you move B as the first/last child of A, or A as the first/last child of B;… you can potentially have edge cases that corrupt your data.