Jump to content
NikNak

Moving page parent via API resulting in Redirect Error on front end

Recommended Posts

Hi

This script for moving past events to a different parent has been working fine for a few years, but in the last few months it has resulted in the moved pages having re-direct errors on the front end (ERR_TOO_MANY_REDIRECTS). If I move the pages manually it is fine... so I am wondering what is causing this now. Would I be correct in assuming this is something to do with Page Path History.  (I have updated the wire folder a couple of times and I am currently on 3.0.127 Dev.)

Any help gratefully received.

$old_events = $pages->find("template=event, parent=1039, include=all"); 
foreach($old_events as $event) {
    $event->of(false);
    $date = date("Ymd", $event->get("date_end|date_start"));
    if ($today > $date) {
        $event->parent=2388;
        $event->save();
    }
    $event->of(true);
}

Share this post


Link to post
Share on other sites

Try in incognito mode to make sure your browser is not caching old redirects.

You could also use the "What other URLs redirect to this page?" section (introduced in PW 3.0.118) and/or the modules below to look for any circular redirects (if such a thing is possible with Page Path History).

This second module needs the PagePaths module installed and also needs a variable name fixed as per a reply in the support topic.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for the suggestions... 

It isn't a browser caching issue for sure. The module Bernhard kindly suggested, just shows that it redirects to itself endlessly (and not back and forth between different urls). For a specific problem page, I have gone into the db and removed all page path history entries for that page id (rather than download modules), but the problem isn't resolved. This leads me to another possibility...

The pages here are named with the page id (ie /whats-on/past-events/5336/ is the full path). Looking at how you can now use any shortcode url that features the page's id, I wonder if pw is seeing the pages name, and seeing it as a shortcode, and redirecting it to the same url. In which case, why is the problem resolved by me manually moving the page to a different parent and then back again, in the page tree, rather than doing it via the API?  (However, I noticed is that my page moving script doesn't create a corresponding entry in the page path history.)

My tests seem to be inconclusive... some pages moved by my script cause redirect errors and some don't, despite being the same types of page and undergoing the same process.

V confused... as this was all working fine for a couple of years.

Many thanks
Nik

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...