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

BUG Fix orphaned pages reporting they can be viewed #991

Merged
merged 1 commit into from
Apr 7, 2014

Conversation

tractorcow
Copy link
Contributor

This issue resolves problems with orphaned pages appearing in search results. This issue has actually appeared in several places in the past, and was typically patched where it was found (e.g. in google sitemaps). This fix resolves the problem closer to the root, ensuring that the default behaviour acts a little more consistently.

$member = new Member();
$member->Email = 'someguy@example.com';
$member->write();
$member->Groups()->add($group);
Copy link
Member

Choose a reason for hiding this comment

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

Should this level of setup be left to the fixtures file rather than test code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, it would result in a cleaner test case.

@wilr
Copy link
Member

wilr commented Apr 7, 2014

Ran into this issue myself after a db migration. Changes would resolve the issues I had. I wonder if we need a report in the reports module as well for orphaned pages (just as an aside).

$this->assertTrue($staff->canView($member));

// Cleanup
Versioned::set_reading_mode($origStage);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure the best way to handle this (probably hard code the default the reading mode in setup?) but if the test itself fails the assertion then this code won't be called right? Might just be one of those things that one breakage, causes a chain of failures and not much we can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Versioned is typically a problem across the test cases; I admit this isn't the best handling of versioned state. I'll fix it in this fixture at least.

@wilr
Copy link
Member

wilr commented Apr 7, 2014

What is the potential of the performance hit of doing this on canView() rather than an pre / post check operation (i.e on publish of the source page)..

@tractorcow
Copy link
Contributor Author

Hey @wilr thanks for the review.

The problem is that there are plenty of valid use cases where a page should be orphaned; If a parent is temporarily unpublished, we don't want child pages showing up in fulltext search, for instance. It's not an "error" we can (or should) catch at publish or unpublish stage.

wilr added a commit that referenced this pull request Apr 7, 2014
BUG Fix orphaned pages reporting they can be viewed
@wilr wilr merged commit f40de3b into silverstripe:3.1 Apr 7, 2014
@wilr
Copy link
Member

wilr commented Apr 7, 2014

True. Considering that a page without a parent may cause sites to break easily figure 3.1 is appropriate as well.

@tractorcow tractorcow deleted the pulls/3.1-canview-orphaned branch April 7, 2014 23:05
@tractorcow
Copy link
Contributor Author

Thanks @wilr :)

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.

4 participants