-
Notifications
You must be signed in to change notification settings - Fork 261
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
Fix for #332: adjacent items for unsorted connections #370
base: master
Are you sure you want to change the base?
Conversation
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. |
else // connection is unsorted | ||
{ | ||
$relatives = $this->get_connected( $result['parent'], | ||
array(), 'abstract' )->items; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only fetch the first 10 connections, so it will return incorrect results if there are more than 10 items in a series.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh that sucks, can this be fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could replace array()
with array( 'p2p:per_page' => -1 )
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this revision is safe to use right?
Ok, the diff looks decent now. I would like to see a unit test for this in |
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 (3e55425) to see the |
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 :) |
Not as fast as default behaviour, but still.
#332