-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW Return 404 when redirector page wants to link to missing page #2663
Conversation
Another option for this is that we have a configurable private static along the lines of '404 on fail' that is false by default to retain the current behaviour. They would make it easier / more obvious for other developers to change to this behaviour since it's just a config flag rather than having to write an new extension class I think this may be a better option because I cannot think of any other useful behaviour that would be implemented in the extension hook. |
I'm honestly finding the approach in this PR a bit weird The existing logic on this function is:
The default text for The reason for PR being raised as I understand it was because a cms author had changed a previous regular page into a redirector page, so it retained the old $page->Content (which they're no longer able to edit because that FormField is not shown in the CMS) Repurposing an old page seems like a fairly reasonable thing for a CMS author to do with old content. It became a problem when the page being redirected to was archived and the link no longer worked I really don't think that adding an extension hook and attempting to fix this with custom code on a case by case basis is pretty sub-optimal A 404 is also potentially wrong here since that should be returned for the URL of the archived target page, though the redirector page should still return a 301/302. Unfortunately we no longer know what the target URL should be as the target page and corresponding URLSegment has been archived. A redirect to the home page is probably not a bad default for Live pages where redirection is not working, though Draft previews should show the contents of getContent() so that CMS authors get feedback that they need to do something @clarkepaul do you have any views on this? |
do or don't think it's sub-optimal? From my perspective, a redirector page shouldn't really hold any content, so if the destination page is not found, return standard 404 using the error page if present. If the destination does exist, redirect with 301/302. Nothing more, nothing less. |
I think a 404 page is better than sending them to the home page. I don't think the redirector page should be triggered to be unpublished unless the CMS user has opted into it. I think we need to empower so "CMS authors get feedback that they need to do something", for instance when unpublishing they get a warning that other pages are linked to it prior to unpublish/archiving. This is probably a separate but related issue, reports page related, or reason to look into CMS notifications. |
I like your quote @clarkepaul about empowering CMS authors and thus makes sense to empower Devs as well if CMS authors needs help in this case as well as for backwards compatibility. This is the mean reason I think of extension hook which gives Devs flexibility whether the old behaviour is correct or wrong. |
@emteknetnz @michalkleiner @clarkepaul Thanks for the feedback. Have updated my pull request taking points from all. |
I agree with the overall approach that if a redirector page points to a missing page, then it should return 404. Also we should provide a clear/easy way for these dependent pages to be found and/or automatically unpublished |
0181b9d
to
85911e7
Compare
My suggested approach to this would be:
|
a4f908c
to
652dd82
Compare
652dd82
to
14c34cf
Compare
14c34cf
to
ab95edd
Compare
I've retargetted this to One test is still failing but I ran out of time to look into it - I'll look at it in the new year but @ssmarco this is still your PR, so if you want to keep working on it and fix that failing test before I get to it that'd be amazing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a quick unit test for the scenario for redirecting to a file
Added test scenario for files to the existing test via the dataprovider. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, works good
Issue #2665
I recently got a ticket where content authors have quite a number of RedirectorPages
and that they find it hard to track which ones to update whenever they unpublish the original page.
It makes more sense to them that whenever they unpublish a page, the RedirectorPage should display 404 as well.
This is quite opposite with the existing behaviour where the RedirectorPage maintains a published state.
Adding an extension point in this case provides additional flexibility.