Jump to content

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


NikNak
 Share

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);
}

Link to comment
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
Link to comment
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

 

Link to comment
Share on other sites

  • 5 months later...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...