From 62b7955406d62f68c0d89f2b2f838586084cdc2d Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 2 May 2024 17:17:57 -0400 Subject: [PATCH 1/2] Digital PCT265 defect CXTDT-552909 - Client crash prevention on invalid module JSON. --- MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index f2af3c3..4f90380 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -365,6 +365,16 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; - (void)addModulesToCache:(nonnull NSDictionary *)jsonDictionary queue:(nullable NSOperationQueue *)queue waitUntilFinished:(BOOL)waitUntilFinished completionBlock:(nullable void (^)(void))completionBlock { [jsonDictionary enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + if (![obj isKindOfClass:[NSDictionary class]]) { + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] + initWithTitle:nil + messageToLog:[NSString stringWithFormat:@"Invalid module format. Cannot cache %@ as it's not an object", key] + code:ErrorCodeJSONNotDictionary + domain:ErrorDomainSystem + location:NSStringFromClass([self class])]; + [MVMCoreLoggingHandler.sharedLoggingHandler addErrorToLog:error]; + return; + } [self addModuleToCache:obj module:key]; }]; __weak typeof(self) weakSelf = self; From d2572c45434907a19a686da95605aa857c02b2c6 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 20 May 2024 16:44:10 -0400 Subject: [PATCH 2/2] Digital ACT191 story ONEAPP-7459 - Update for convenience in registration of models that replace --- MVMCore/MVMCore/Models/Model/ModelRegistry.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index 65e413d..dbb2afa 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -50,9 +50,9 @@ public struct ModelRegistry { /// A convenience wrapping function where error handling is managed within the class. /// - Parameter type: Takes an object of ModelProtocol.self which is used to register - public static func register(_ type: M.Type) { + public static func register(_ type: M.Type, allowsReplace: Bool = false) { do { - try throwable_register(type: type) + try throwable_register(type: type, allowsReplace: allowsReplace) } catch { handleError(error) }