wp-posts-to-posts
wp-posts-to-posts copied to clipboard
Fix for #332: adjacent items for unsorted connections
Not as fast as default behaviour, but still. #332
Please describe your solution in a few words (it's not very clear by looking at the diff).
A single loop of all relatives. They are already sorted by WP, so it's looking for current object.
filter_where
filters both sides of connection - not really useful here, and raw SQL is too crude.
Ok, the diff looks decent now.
I would like to see a unit test for this in tests/test-core.php
. See CONTRIBUTING.md for instructions.
Erm... the instructions for running the unit tests are incomplete. I'll update them soon.
Even so, they probably don't work on Windows, unless you have Cygwin.
However, you can try to commit a first draft and push it to the branch; it'll get run by the build server (Travis CI).
There: https://github.com/scribu/wp-posts-to-posts/blob/master/CONTRIBUTING.md#unit-tests
You'll need to switch to the latest master branch (3e5542548f51b757e117612f94d1b75f43d1b573) to see the ./bin/install-wp-tests
script.
It says the following: "Good to merge — The Travis CI build passed (Details)"
Does this mean that everything is handled and it'll be in the normal posts-to-posts plugin soon?
The "The Travis CI build passed" message just means that the current patch passes all existing unit tests.
If you want to help, you can start using Oreolek's fork and report back any problems you find.
Alright cool! Thanks. But by looking at the code you think it's safe to use right?
It's safe in the sense that it won't delete your connections or anything like that. :P
I have no idea if it fetches the correct posts, what happens if you have many posts etc. That's why I'm asking you to try it out, since you already have a use-case for it.
I'm testing it right now :) It seems to work pretty great.
Tested with the same code that you gave me before @scribu without turning sorting on it seems to work perfectly. Seems to work with 600+ connections.
http://phanime.com/anime/one-piece/
^ Click on one of the episodes (out of 600) and you can go next and previous. Seems to work pretty great :)