adrian Posted May 30, 2019 Share Posted May 30, 2019 What does everyone think of this? Shouldn't they both return NullPage? I'd love to hear your thoughts. Thanks! Link to comment Share on other sites More sharing options...
Lutz Posted May 30, 2019 Share Posted May 30, 2019 get() should return a NullPage in both cases, if $categories returns a PageArray. Since find() could return a PageArray or an array: what does $categories return? 1 Link to comment Share on other sites More sharing options...
adrian Posted May 30, 2019 Author Share Posted May 30, 2019 2 minutes ago, Lutz said: get() should return a NullPage in both cases, if $categories returns a PageArray. Since find() could return a PageArray or an array: what does $categories return? Thanks for chiming in! Here are some more outputs which I think help to back up the assertion that it should return a NullPage Link to comment Share on other sites More sharing options...
Lutz Posted May 30, 2019 Share Posted May 30, 2019 You are right: $categories returns a PageArray, so I thought that get() should return a NullPage in both cases. Link to comment Share on other sites More sharing options...
Lutz Posted May 30, 2019 Share Posted May 30, 2019 @adrian I think we were wrong. $pages->get() should return a NullPage, but with $categories->get() you are using WireArray::get()!? Link to comment Share on other sites More sharing options...
bernhard Posted May 30, 2019 Share Posted May 30, 2019 Have you had a look at PageArray.php? And in WireArray.php: Not sure if it should return a NullPage or null/false - but I guess it should be consistent... To add one more: findOne() returns "false" ? 1 Link to comment Share on other sites More sharing options...
adrian Posted May 30, 2019 Author Share Posted May 30, 2019 I hadn't looked - thanks for posting that - it's pretty clear from that @todo that Ryan know about this and that it needs fixing. Obviously calling findOne() if it's a selector isn't enough to get it to return NullPage as things currently stand, but this really should be fixed because with the current behavior you can't simply do a normal: if($result->id) on an in memory selector that returns no results because of the null vs NullPage - this has annoyed me for a long time ? 2 Link to comment Share on other sites More sharing options...
adrian Posted May 30, 2019 Author Share Posted May 30, 2019 https://github.com/processwire/processwire-issues/issues/896 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now