Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Fix for #332: adjacent items for unsorted connections #370

wants to merge 6 commits into from

Conversation

Oreolek
Copy link

@Oreolek Oreolek commented Jun 4, 2013

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

@scribu
Copy link
Owner

scribu commented Jun 4, 2013

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

@Oreolek
Copy link
Author

Oreolek commented Jun 4, 2013

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.

else // connection is unsorted
{
$relatives = $this->get_connected( $result['parent'],
array(), 'abstract' )->items;
Copy link
Owner

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.

Copy link

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?

Copy link
Owner

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

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?

@scribu
Copy link
Owner

scribu commented Jun 11, 2013

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
Copy link
Owner

scribu commented Jun 11, 2013

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
Copy link
Owner

scribu commented Jun 11, 2013

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 ./bin/install-wp-tests script.

@JamesGot
Copy link

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?

@scribu
Copy link
Owner

scribu commented Jun 22, 2013

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.

@JamesGot
Copy link

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

@scribu
Copy link
Owner

scribu commented Jun 24, 2013

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.

@JamesGot
Copy link

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

@faeronsayn
Copy link

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

@scribu scribu removed this from the next milestone Apr 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants