Memorize query results in blog service (#8374)

The query for all published blogs is being called twice while building the admin menu,
so we are memorizing its results.
This commit is contained in:
Matteo Piovanelli
2020-05-14 19:29:59 +02:00
committed by GitHub
parent 9392718d3e
commit f581d235d2

View File

@@ -51,8 +51,14 @@ namespace Orchard.Blogs.Services {
return blogPart == null ? null : blogPart.ContentItem;
}
private IEnumerable<BlogPart> _publishedBlogs;
public IEnumerable<BlogPart> Get() {
return Get(VersionOptions.Published);
// this is currently called at least twice per request on the
// back-office, both times by the code building the admin menu.
if (_publishedBlogs == null) {
_publishedBlogs = Get(VersionOptions.Published);
}
return _publishedBlogs;
}
public IEnumerable<BlogPart> Get(VersionOptions versionOptions) {