Jump to content

problem with page parent change in admin tree


valan
 Share

Recommended Posts

Code below works everywhere else, except if applied to pages in Admin tree. Specifically, I change parent to some 'user-car' pages and place them under some 'user' page in admin tree.

$page->of(false);
$page->parent = $some_user_page;
$page->save();

$page->save() freezes, e.g. method does not not return any value/looks like in falls in endless loop somewhere inside. It also does not generate any errors.

As it happens only in Admin tree (everywhere else it works), root cause could be:

(1) in template settings (I've checked and didn't found any "restrictions", e.g. 'user-car' pages can be freely moved, 'user' may have children) or

(2) in core code, somewhere in Page::save()

Please, advise how to fix this issue.

Link to comment
Share on other sites

1. specify a template
2. check if the parent you have set exists

$page->of(false);
$page->template = 'whatever';
$page->parent = $some_user_page;
if ($page->parent->id && $page->template->id) $page->save();
else die('Something went wrong');

or use a debugging tool.

  • Like 1
Link to comment
Share on other sites

@kixe thanks. $page already exists, so no need to set template again. Anyway, I did it but issue remained - the same $page->save(). I'm not really advanced enough programmer to debug PW core code (and don't have proper debugging tools, wire('log')->error('My error'); was always enough for me)) 

Link to comment
Share on other sites

1 minute ago, valan said:

don't have proper debugging tools

Now you do ^_^

2 minutes ago, valan said:

I'm not really advanced enough programmer to debug PW core code.

Me neither, but I do know getting familiair with Tracy saved a lot of my time the last year.

  • Like 1
Link to comment
Share on other sites

@arjen thanks. I guess that such kind of errors like "endless loops somewhere in the core" require line-by-line execution debugger in order to find where it occurs. Not sure that Tracy may help here, but will give it a try.

I also think its a core issue, not site-specific. Could you check it in admin? - move any page under any user (preliminary make sure you've enabled 'may have children' in user template). Page will be moved, but spinner will continue to run, blocking any further work in admin, so you'll need to create a new session (restart browser/login again).

Link to comment
Share on other sites

49 minutes ago, valan said:

Could you check it in admin? - move any page under any user (preliminary make sure you've enabled 'may have children' in user template). Page will be moved, but spinner will continue to run, blocking any further work in admin, so you'll need to create a new session (restart browser/login again).

Moving a page via the admin interface so it is placed under a user page works okay for me. But regarding the idea of placing pages under a user page, this post sounds like sensible advice:

 

  • Like 1
Link to comment
Share on other sites

3 minutes ago, Robin S said:

Moving a page via the admin interface so it is placed under a user page works okay for me.

@Robin S thanks for check. Looks like problem is deeper. May be at MySQL level as we've migrated to InnoDb. Or smth else. And thanks for sensible advice!

Link to comment
Share on other sites

2 hours ago, valan said:

Not sure that Tracy may help here, but will give it a try.

Since you not know, you could step-by-step by checking what $page is, what $some_user_page is, et cetera. First check your own data, if you are sure that the pages are what you expect them to be and the config of the templates is correct you should look deeper.

  • Like 2
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

×
×
  • Create New...