bernhard Posted March 26 Share 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? Link to comment Share on other sites More sharing options...
elabx Posted Wednesday at 03:30 PM Share Posted Wednesday at 03:30 PM I think $parent is the second parameter not the recursive flag (which is true by default)? 🤔 Link to comment Share on other sites More sharing options...
bernhard Posted Wednesday at 04:07 PM Author Share Posted Wednesday at 04:07 PM 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 More sharing options...
elabx Posted Wednesday at 04:39 PM Share Posted Wednesday at 04:39 PM On 3/26/2025 at 4:07 PM, bernhard said: so using "recursive: false" should set the "$recursive" parameter (which is the third) and the second should default to null either way. Expand I completely missed this syntax! I am living in the PHP of the past 😭 1 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