wp-posts-to-posts icon indicating copy to clipboard operation
wp-posts-to-posts copied to clipboard

Fix for #332: adjacent items for unsorted connections

Open Oreolek opened this issue 11 years ago • 11 comments

Not as fast as default behaviour, but still. #332

Oreolek avatar Jun 04 '13 00:06 Oreolek

Please describe your solution in a few words (it's not very clear by looking at the diff).

scribu avatar Jun 04 '13 00:06 scribu

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.

Oreolek avatar Jun 04 '13 00:06 Oreolek

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.

scribu avatar Jun 11 '13 11:06 scribu

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

scribu avatar Jun 11 '13 11:06 scribu

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.

scribu avatar Jun 11 '13 12:06 scribu

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?

JamesGot avatar Jun 22 '13 20:06 JamesGot

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.

scribu avatar Jun 22 '13 20:06 scribu

Alright cool! Thanks. But by looking at the code you think it's safe to use right?

JamesGot avatar Jun 24 '13 18:06 JamesGot

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.

scribu avatar Jun 24 '13 19:06 scribu

I'm testing it right now :) It seems to work pretty great.

JamesGot avatar Jun 25 '13 04:06 JamesGot

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

faeronsayn avatar Jun 25 '13 07:06 faeronsayn