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

DataList->column mutates underlying DataQuery #9641

Closed
MasonD opened this issue Aug 18, 2020 · 3 comments
Closed

DataList->column mutates underlying DataQuery #9641

MasonD opened this issue Aug 18, 2020 · 3 comments

Comments

@MasonD
Copy link
Contributor

MasonD commented Aug 18, 2020

Affected Version

Silverstripe 4.5

Description

DataList->column calls distinct(false) on its DataQuery without cloning it first, causing errors if the DataList is used for anything else afterwards.

Steps to Reproduce

Have a member in multiple groups. Run the following code.

$members = Member::get()->applyRelation('Groups.ID');
$members->column('ID'); // This mutates the DataQuery of $members and removes distinct.
foreach ($members as $member) {
    echo $member->Name . "\n"; // members with multiple groups are represented multiple times
}
@sminnee
Copy link
Member

sminnee commented Aug 18, 2020

Nice find - do you want to do a pull request?

@MasonD
Copy link
Contributor Author

MasonD commented Aug 19, 2020

Sure thing. Which branch should I target?

@sminnee
Copy link
Member

sminnee commented Aug 19, 2020

Since it's a bug I think 4.6 is fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants