Skip to content

Make page()->child() take an int to conform with the docs. #296

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wire/core/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,7 @@ public function findOne($selector = '', $options = array()) {
* #pw-group-common
* #pw-group-traversal
*
* @param string $selector Selector to use, or omit to return all children.
* @param string|array $selector Selector to use, or omit to return all children.
* @param array $options Optional options to modify behavior, the same as those provided to Pages::find.
* @return PageArray|array Returns PageArray for most cases. Returns regular PHP array if using the findIDs option.
* @see Page::child(), Page::find(), Page::numChildren(), Page::hasChildren()
Expand Down
4 changes: 3 additions & 1 deletion wire/core/PageTraversal.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function children(Page $page, $selector = '', $options = array()) {
* Same as children() but returns a Page object or NullPage (with id=0) rather than a PageArray
*
* @param Page $page
* @param string|array $selector Selector to use, or blank to return the first child.
* @param string|array|int $selector Selector to use, or blank to return the first child.
* @param array $options
* @return Page|NullPage
*
Expand All @@ -150,6 +150,8 @@ public function child(Page $page, $selector = '', $options = array()) {
if(is_array($selector)) {
$selector["limit"] = 1;
$selector[] = array("start", "0");
} else if (($id = (int)$selector) && $id > 0) {
$selector = [ 'id' => $id, 'limit' => 1 ];
} else {
$selector .= ($selector ? ', ' : '') . "limit=1";
if(strpos($selector, 'start=') === false) $selector .= ", start=0"; // prevent pagination
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy