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: Use Hierarchy::prepopulateTreeDataCache() in CMS. #183

Merged
merged 2 commits into from
Sep 25, 2018
Merged

FIX: Use Hierarchy::prepopulateTreeDataCache() in CMS. #183

merged 2 commits into from
Sep 25, 2018

Conversation

sminnee
Copy link
Member

@sminnee sminnee commented Sep 21, 2018

Doesn't do anything without silverstripe/silverstripe-framework#8395

* @param array $options A map of hints about what should be cached. "numChildrenMethod" and
* "childrenMethod" are allowed keys.
*/
public function onPrepopulateTreeDataCache(DataList $recordList = null, array $options = [])
Copy link
Contributor

Choose a reason for hiding this comment

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

I updated Hierachy::prepopulateTreeDataCache to accept an array of IDs as well as DataList. My rational at the time was that if I'm getting a list of IDs as parameters on a request it sounds counter-intuitive that I should fetch them so I can cache something about them.

Ideally onPrepopulateTreeDataCache should mimic this behavior as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

For simplicity, we can probably refactor the whole thing to only receive an ID list.

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, scratch that. DataList would be the only way that you could supply a lazily-evaluated list, since we can't use "iterable" as a typehint in PHP 5.6/7.0.

@maxime-rainville
Copy link
Contributor

If we update the unit test to use the onPrepopulateTreeDataCache extension hook instead of prepopulate_versionnumber_cache, that should take care of the codecov/patch warning.

@maxime-rainville maxime-rainville merged commit 05b372c into silverstripe:1 Sep 25, 2018
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.

2 participants