bernhard Posted March 26 Posted March 26 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?
elabx Posted March 26 Posted March 26 I think $parent is the second parameter not the recursive flag (which is true by default)? 🤔
bernhard Posted March 26 Author Posted March 26 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
elabx Posted March 26 Posted March 26 31 minutes ago, bernhard said: so using "recursive: false" should set the "$recursive" parameter (which is the third) and the second should default to null either way. I completely missed this syntax! I am living in the PHP of the past 😭 1
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