From 82ba1a24a3492ad399e3f5389743368ab199c8be Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 17 Feb 2014 15:45:36 +1100 Subject: [PATCH] Ensures we perform null checks in both GetAll and GetByQuery as we never want to include a null item in the resultant collection - which could happen depending on what the sub class repository is doing. Fixes: U4-3145 Cache file periodically becomes corrupted: "Oops: this document is published but is not in the cache (internal error)" --- .../Persistence/Repositories/RepositoryBase.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs index 6a896a54cb..05b8c84fd1 100644 --- a/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs @@ -154,7 +154,10 @@ namespace Umbraco.Core.Persistence.Repositories } } - var entityCollection = PerformGetAll(ids).ToArray(); + var entityCollection = PerformGetAll(ids) + //ensure we don't include any null refs in the returned collection! + .WhereNotNull() + .ToArray(); foreach (var entity in entityCollection) { @@ -175,7 +178,9 @@ namespace Umbraco.Core.Persistence.Repositories /// public IEnumerable GetByQuery(IQuery query) { - return PerformGetByQuery(query); + return PerformGetByQuery(query) + //ensure we don't include any null refs in the returned collection! + .WhereNotNull(); } protected abstract bool PerformExists(TId id);