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

isChildOf() method always returns `true` #2255

Closed
texnixe opened this issue Oct 28, 2019 · 6 comments

Comments

@texnixe
Copy link
Contributor

@texnixe texnixe commented Oct 28, 2019

Describe the bug
Whatever you pass to the isChildMethod() it always returns true.

Let's say you are in the Starterkit and add the following code in the note.phptemplate:

var_dump($page->isChildOf('notes'));

rightly returns true, but

var_dump($page->isChildOf('photography'));

falsely also returns true.

Expected behavior
The method should create a page object from a string if a string is passed and then compare the parent to that the given page or the page created from the string.

Kirby Version
3.0.0-rc-1

@afbora

This comment has been minimized.

Copy link
Contributor

@afbora afbora commented Oct 28, 2019

Isn't it natural that it always returns true? It was a self-validating method 😅

var_dump($page->isChildOf('no-exists-page')); // true :)
public function isChildOf($parent): bool
{
    if ($parent = $this->parent()) {
        return $parent->is($parent);
    }

    return false;
}

https://github.com/getkirby/kirby/blob/release/3.3.0/src/Cms/Page.php#L632-L639

@texnixe

This comment has been minimized.

Copy link
Contributor Author

@texnixe texnixe commented Oct 28, 2019

You're right, I thought so. So the whole method is pretty useless as it is.

@texnixe texnixe changed the title Passing a string to isChildOf() returns false `true` isChildOf() method always returns `true` Oct 28, 2019
@lukasbestle lukasbestle added this to the 3.3.1 milestone Oct 28, 2019
@lukasbestle

This comment has been minimized.

Copy link
Contributor

@lukasbestle lukasbestle commented Oct 28, 2019

OMG, that's a stupid bug. :D

@benoitwimart

This comment has been minimized.

Copy link

@benoitwimart benoitwimart commented Oct 29, 2019

So, I really found a bug !

@bastianallgeier

This comment has been minimized.

Copy link
Contributor

@bastianallgeier bastianallgeier commented Oct 29, 2019

Sorry, but I really have to laugh about the stupidity here 😂 I think we can fix this for 3.3.0

@bastianallgeier bastianallgeier modified the milestones: 3.3.1, 3.3.0 Oct 29, 2019
lukasbestle added a commit that referenced this issue Oct 29, 2019
Closes #2255.
@lukasbestle

This comment has been minimized.

Copy link
Contributor

@lukasbestle lukasbestle commented Oct 29, 2019

Fixed on the 3.3.0 release branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.