Dennis Spohr Posted September 18, 2018 Share Posted September 18, 2018 Hi all, I have a weird behavior. I'm using the following code to clone one of my pages: $block = $salespage->children("id={$duplicate_id},include=all")->first(); $block->of(false); if ($block && $block->id) { $newone = $pages->clone($block); } Problem: the page itself gets cloned, but on of the fields (a repeater) does not get cloned. It's empty. If I do the same in the ProcessWire-Admin via the PageTree, it works fine. The repeater-field gets cloned there as well. What could be the problem? Thanks, Dennis Link to comment Share on other sites More sharing options...
kongondo Posted September 18, 2018 Share Posted September 18, 2018 Not sure if this thread is still relevant? If it is, it seems cloning repeaters can be a pain ?? Btw, this: $block = $salespage->children("id={$duplicate_id},include=all")->first(); Can be shortened to this: $block = $salespage->child("id={$duplicate_id},include=all"); 1 Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 18, 2018 Author Share Posted September 18, 2018 Thanks, I will look into this thead - however I don't understand why it's working on the ProcessWire Admin. It seems that it should work and I'm doing something different than the admin. Thanks for mentioning the child()-function ? Link to comment Share on other sites More sharing options...
bernhard Posted September 18, 2018 Share Posted September 18, 2018 imho it should work, maybe you can try it on a clean installation? 1 Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 21, 2018 Author Share Posted September 21, 2018 I just tried it. On a clean install (3.0.98) it works like it should be. My other installation has the same version. I don't have any idea why it doesn't work there. Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 25, 2018 Author Share Posted September 25, 2018 I have another weird behavior on this. If I use $pages->clone($mypage) I get this error: Quote Exception: Can’t save page 0: /ma/.../video/: Call $page->of(false); before getting/setting values that will be modified and saved. [Page::statusCorrupted] fields: align, textalign, position Looks like somehow something is corrupt. But I don't have any idea why and how to fix it. Link to comment Share on other sites More sharing options...
bernhard Posted September 25, 2018 Share Posted September 25, 2018 On 9/21/2018 at 10:46 PM, Dennis Spohr said: I just tried it. On a clean install (3.0.98) it works like it should be. 19 minutes ago, Dennis Spohr said: If I use $pages->clone($mypage) I get this error: Quote Exception: Can’t save page 0: /ma/.../video/: Call $page->of(false); before getting/setting values that will be modified and saved. [Page::statusCorrupted] fields: align, textalign, position Looks like somehow something is corrupt. But I don't have any idea why and how to fix it. If it works on a clean install there is something else causing this problem. Most likely there's a hook somewhere that does additional things on Pages::saved or Pages::saveReady; This can be either in ready.php or in any of your modules. I'd start by commenting out all the content of ready.php, then disabling all modules one by one (by adding a dot in front of the folder name). If anything of that works you can begin to narrow it down in that area. Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 25, 2018 Author Share Posted September 25, 2018 I removed my ready.php and removed all modules in my site/modules folder. But nothing changed. Is it possible that something is corrupted? Because of this part in the error message: Page::statusCorrupted] fields: align, textalign, position Link to comment Share on other sites More sharing options...
bernhard Posted September 25, 2018 Share Posted September 25, 2018 Backup your data. Look at your table "pages" and sort by page status. I guess you'll find some pages having status 13x.xxx (cant remember the exakt code, it's something over 130k). try to set page status to 1 and see if that make a difference. Where do you clone your page? In a module? Inside Tracy? In a template? Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 25, 2018 Author Share Posted September 25, 2018 There is no page with status = 131073. I'm trying to clone the page in my template. Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 25, 2018 Author Share Posted September 25, 2018 I was able to solve one of the problems. For a field of type Select Options I was setting a value which was not existing. When I'm doing the page-clone now, I don't get any error anymore. But still, the repeater-fields don't get copied. Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 25, 2018 Author Share Posted September 25, 2018 Finally I was able to reproduce the problem on the clean install of ProcessWire. It seems to be a problem with a SelectOptions-FIeld, when no value is set. I did the following on the clean install: Create a new SelectOptions-Field with some values in it. Assign the field to a template Create a new Page of this template using the API: $mypage = new Page(); $mypage->template = 'basic-page'; $mypage->parent = $pages->get(1); $mypage->title = 'TEST'; $mypage->save(); print ($mypage->id); Copy the ID of the new page and do the following: $mypage = $pages->get(1042); $pages->clone($mypage); While doing this I get this exception: Quote Error: Exception: Can’t save page 0: /test-1/: Call $page->of(false); before getting/setting values that will be modified and saved. [Page::statusCorrupted] fields: images, selectoptions (in D:\xampp\htdocs\pw-test\wire\core\PagesEditor.php line 515) selectoptions is the name of my SelectOptions-Field. Settings $page->selectoptions = ''; seems to create the same problem (no value set). I don't think this should be the expected behavior? Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 25, 2018 Author Share Posted September 25, 2018 I just created an issue for this: https://github.com/processwire/processwire-issues/issues/711 Link to comment Share on other sites More sharing options...
bernhard Posted September 25, 2018 Share Posted September 25, 2018 I cannot confirm that. Everything is working as expected: ProcessWire 3.0.114 Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 25, 2018 Author Share Posted September 25, 2018 Probably it got fixed already? Because I tested it with ProcessWire 3.0.98. Link to comment Share on other sites More sharing options...
bernhard Posted September 25, 2018 Share Posted September 25, 2018 yes: But it works if I do what the error says: Calling $pages->of(false) before: Link to comment Share on other sites More sharing options...
Dennis Spohr Posted September 26, 2018 Author Share Posted September 26, 2018 Quote But it works if I do what the error says: Calling $pages->of(false) before: Yes, but it does not work if you have child-pages with a SelectOptions-Field. Thank you very much for all your help and support! I will check with the latest developer-version. Link to comment Share on other sites More sharing options...
bernhard Posted September 26, 2018 Share Posted September 26, 2018 That's not true, please could you prove your statements with screenshots or the like and not just tell "it's not working"? And the current DEV: Recursive: Quote Thank you very much for all your help and support! I will check with the latest developer-version. You're welcome ? Yep, no reason not to use it IMHO. 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