Jump to content

$pages->clone() not working as expected with recursive parameter?


bernhard
 Share

Recommended Posts

Today I used this:

$clone = wire()->pages->clone($p, recursive: false);

And I wondered why it was still cloning my page "$p" recursively with all its children...

Then I tried this:

$clone = wire()->pages->clone($p, null, false);

Which worked as expected. I looked into the code but was not able to find an explanation. AI was also not helpful in this case.

Any ideas?

Link to comment
Share on other sites

Hey @elabx thx for joining! Yes, but using named arguments it should not matter, so using "recursive: false" should set the "$recursive" parameter (which is the third) and the second should default to null either way. But something is not working as it should in my opinion, so something is wrong either in my head or in the core ^^

PS: Here are the links to the methods in the core:

Pages::___clone = https://github.com/processwire/processwire/blob/44fcf13ea2d7f14a04eed54c29afcc79eb46ec45/wire/core/Pages.php#L1047

PagesEditor::_clone = https://github.com/processwire/processwire/blob/44fcf13ea2d7f14a04eed54c29afcc79eb46ec45/wire/core/PagesEditor.php#L1324

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