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

FIX Don’t override ItemRequest if already versioned #60

Merged

Conversation

wilr
Copy link
Member

@wilr wilr commented Oct 23, 2017

If a developer customises the ItemRequest don’t override it as long as it is already a versioned item hander.

}

try {
$obj = new ReflectionClass($class);
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to use Reflection to find out if a class is a subclass of another. is_subclass_of or is_a will do.

Copy link
Member Author

@wilr wilr Oct 23, 2017

Choose a reason for hiding this comment

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

Ah sweet Dan! I had thought those only worked on instances of $class rather than just names. Nice change in 5.3.9

@wilr wilr force-pushed the pulls/prevent-version-override branch from fd9aa21 to 285c61c Compare October 23, 2017 17:11
if ($record
&& $record->has_extension(Versioned::class)
&& $record->config()->get('versioned_gridfield_extensions')
) {
$class = VersionedGridFieldItemRequest::class;
// don't override custom classes if they already subclass this
if (!$class) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These conditions can be combined

Copy link
Member Author

Choose a reason for hiding this comment

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

How'd you mean?

@robbieaverill robbieaverill changed the base branch from 1 to 1.0 October 25, 2017 08:16
wilr and others added 2 commits October 25, 2017 21:16
If a developer customises the ItemRequest don’t override it as long as it is already a versioned item hander.
@robbieaverill
Copy link
Contributor

@dhensby Will's on leave at the moment - I assume you mean that the if statements in this can be consolidated into one, so I've pushed a fix for that. Would you mind re-checking when you have time please?

If this is a bug fix, do you think we could sneak it into 1.0 before a stable release?

I hope we can, so have switched the branch to 1.0.

@dhensby
Copy link
Contributor

dhensby commented Oct 25, 2017

much better, thanks

@dhensby dhensby merged commit 178b001 into silverstripe:1.0 Oct 25, 2017
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.

None yet

3 participants