Skip to content
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

WIP: BUGFIX: Create a 410-Gone redirect for deleted nodes #32

Closed

Conversation

mficzel
Copy link
Member

@mficzel mficzel commented Jan 30, 2019

If a node cannot be read in the createPendingRedirects stage it is considered to have been deleted and the removeNodeRedirect method is triggered.

I addition the restrictions are applied in the collect stage to work on removed nodes but
also to work on the origin before the publishing as specified in the docs.

fixes: #31

{
// By default the redirect handling for removed nodes is activated.
// If it is deactivated in your settings you will be able to handle the redirects on your own.
// For example redirect to dedicated landing pages for deleted campaign NodeTypes
if ($this->enableRemovedNodeRedirect) {
$hosts = $this->getHostnames($node->getContext());
$this->flushRoutingCacheForNode($node);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it unproblematic that the routing cache is not informed about the removed node anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, it would have to be informed at the collect stage anyways since the node is not there anymore during redirect creating.

Also i assume that other components are informing the routing cache that a node was deleted already. Maybe @kitsunet can tell.

Copy link
Contributor

@gerhard-boden gerhard-boden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good by reading, another test could be added to check if the behavior is also correct when the node is hidden from the live workspace (which it should codewise)

@mficzel mficzel requested a review from grebaldi January 31, 2019 07:46
| user-testaccount |
And I remove the node
And I publish the workspace "user-testaccount"
And I should have a redirect with sourceUri "en/about.html" and statusCode "410"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
And I should have a redirect with sourceUri "en/about.html" and statusCode "410"
Then I should have a redirect with sourceUri "en/about.html" and statusCode "410"

@gerhard-boden
Copy link
Contributor

gerhard-boden commented Jan 31, 2019

You could try this (test is untested 😄 )

  @fixtures
  Scenario: Hidden nodes create a redirect with 410 Status
    When I get a node by path "/sites/behat/about" with the following context:
      | Workspace        |
      | user-testaccount |
    And I hide the node
    And I publish the node
    Then I should have no redirect with sourceUri "en/about.html"

@mficzel
Copy link
Member Author

mficzel commented Feb 1, 2019

@gerhard-boden not creating redirects for hidden nodes is problematic because of this feature here https://github.com/neos/redirecthandler-neosadapter/blob/master/Tests/Behavior/Features/Redirect.feature#L97-L104

Imho the check should be inverted here to verify that no redirect was created.

@gerhard-boden
Copy link
Contributor

gerhard-boden commented Feb 1, 2019

yes, rest of the tests might still be outdated ofc, since we only decided yesterday how to handle hidden nodes 😄 I don't see an issue in dropping / rewriting that test case. I updated my code sample above yesterday after the discussion.

@gerhard-boden
Copy link
Contributor

I wouldn't worry about breakiness either, we never claimed anywhere that it was an explicit feature that we create redirects for hidden nodes and it's a pretty useless feature too in retrospective...

@mficzel mficzel force-pushed the bugfix/createGoneStatusForDeletedDocuments branch from 6db2a25 to 350707c Compare February 1, 2019 17:13
@mficzel
Copy link
Member Author

mficzel commented Feb 1, 2019

@gerhard-boden I added/adjusted the tests for hidden documents.

We should ask @nezaniel about wether removing the flushing of the router cache is safe since he added it with #21. I consider this obsolete since the new architecture should allow to let the routing cache be handles solely by the \Neos\Neos\Routing\Cache\RouteCacheFlusher.

@mficzel mficzel requested a review from nezaniel February 1, 2019 17:21
if ($node->isVisible() === false) {
return;
}

if (!$this->hasNodeUriChanged($node, $targetWorkspace)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hasn't changed with this PR, but I run into this condition all the time, when I'm trying to test the redirects for deleted nodes.

Seems to me that a deleted node does not necessarily come with a detectable URI change.

@mficzel mficzel force-pushed the bugfix/createGoneStatusForDeletedDocuments branch from 350707c to f48432a Compare February 6, 2019 10:59
@mficzel mficzel changed the title BUGFIX: Create a 410-Gone redirect for deleted nodes WIP: BUGFIX: Create a 410-Gone redirect for deleted nodes Feb 7, 2019
@mficzel
Copy link
Member Author

mficzel commented Feb 7, 2019

Stopped working for now since i discovered that the adapter behaves differently in behat. The previous change only worked in behat but not in neos.

I pushed a new changeset that only contained the additional tests as a base to pick this up again later.

@mficzel
Copy link
Member Author

mficzel commented Feb 27, 2019

I close this since the problem somehow is deeper than i thought

@mficzel mficzel closed this Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

410-gone status not generated
3 participants