Jump to content

Weird error with selectors returning root


Adam Kiss
 Share

Recommended Posts

I'm posting this here, rather than on github, because there is fat chance I'm doing something wrong :)

Let me start with my structure [modified page list to show urls]:

processwire-bug-wrongcount-list.png

Now, when I call this:

<?php $pages->find('parent=/news/');

It actually returns 1 page! [it shouldn't] And that one page is... root! (if you guessed right, you're winning imaginary TV $200)

For anyone interested, I replaced that selector with

$pages->get('/novinky/')->children('sort=-date')->slice(0,3);

(yes, it's also enhanced a little, renamed the page that holds news, reversed the array by date and sliced the first three entries :))

Link to comment
Share on other sites

Adam,

Good find. If you issued a get() or find() that includes a "parent=" portion in the selector that didn't resolve to a page, then it would return the homepage. This was due to an error in the PageFinder code that didn't differentiate between 0 (homepage's parent) and null (no parent). This has been fixed and the update committed to GitHub. Thanks for finding this.

Ryan

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...