diff --git a/Modules/Sources/WordPressKitObjC/PostServiceRemoteREST.m b/Modules/Sources/WordPressKitObjC/PostServiceRemoteREST.m index fbc02baeba2c..b4d6f670fe9f 100644 --- a/Modules/Sources/WordPressKitObjC/PostServiceRemoteREST.m +++ b/Modules/Sources/WordPressKitObjC/PostServiceRemoteREST.m @@ -4,6 +4,7 @@ #import "RemotePostTerm.h" #import "FilePart.h" #import "NSString+Helpers.h" +#import "NSString+WPKitNumericValueHack.h" @import WordPressShared; @import WordPressKitModels; @@ -396,7 +397,8 @@ - (RemotePost *)remotePostFromJSONDictionary:(NSDictionary *)jsonPost { + (RemotePost *)remotePostFromJSONDictionary:(NSDictionary *)jsonPost { RemotePost *post = [RemotePost new]; post.postID = jsonPost[@"ID"]; - post.siteID = jsonPost[@"site_ID"]; + // Create and update responses return site_ID as a string, while read responses return a number. + post.siteID = [jsonPost[@"site_ID"] wpkit_numericValue]; if (jsonPost[@"author"] != [NSNull null]) { NSDictionary *authorDictionary = jsonPost[@"author"]; post.authorAvatarURL = authorDictionary[@"avatar_URL"]; diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 423368e006f3..8a2418247261 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -3,7 +3,7 @@ * [*] [internal] In-app updates: guard the flexible update notice against double-posting when two update checks race [#25666] * [*] [build tooling] Add a String Catalog localization pipeline (plurals + build-free catalog generation) with a CI coverage gate [#25688] * [*] [internal] Stats widgets: migrate the site picker from SiriKit to App Intents [#25753] - +* [*] Share Extension: Fix a crash after uploading a post to WordPress.com [#25773] 27.0 ----- diff --git a/Tests/WordPressKitTests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m b/Tests/WordPressKitTests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m index d6ed1b89a6f2..732af74622de 100644 --- a/Tests/WordPressKitTests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m +++ b/Tests/WordPressKitTests/WordPressKitTests/Tests/PostServiceRemoteRESTTests.m @@ -26,6 +26,22 @@ - (PostServiceRemoteREST*)service return [[PostServiceRemoteREST alloc] initWithWordPressComRestApi:api siteID:siteID]; } +#pragma mark - Mapping posts + +- (void)testThatRemotePostMappingConvertsStringSiteIDToNumber +{ + NSDictionary *jsonPost = @{ + @"ID": @1147, + @"site_ID": @"237072388" + }; + + RemotePost *post = [PostServiceRemoteREST remotePostFromJSONDictionary:jsonPost]; + + XCTAssertEqualObjects(post.postID, @1147); + XCTAssertEqualObjects(post.siteID, @237072388); + XCTAssertTrue([post.siteID isKindOfClass:[NSNumber class]]); +} + #pragma mark - Getting posts by ID - (void)testThatGetPostWithIDWorks