Skip to content

Return empty arrays from TaxonomyServiceRemoteREST tag/category mapping - #25969

Open
jkmassel wants to merge 2 commits into
trunkfrom
jkmassel/taxonomy-nil-safe-arrays
Open

Return empty arrays from TaxonomyServiceRemoteREST tag/category mapping#25969
jkmassel wants to merge 2 commits into
trunkfrom
jkmassel/taxonomy-nil-safe-arrays

Conversation

@jkmassel

@jkmassel jkmassel commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Follows the pattern from #25964.

Summary

  • TaxonomyServiceRemoteREST's tag/category fetches call their success blocks — declared NSArray<RemotePostTag *> * _Nonnull / NSArray<RemotePostCategory *> * _Nonnull — with [self remoteTagsWithJSONArray:[responseObject arrayForKey:…]].
  • arrayForKey: returns nil when the key is absent or JSON-null, and [nil wp_map:…] is nil, so a malformed 200 response leaks nil into the _Nonnull block.
  • The Swift caller (TagsService, for .com sites) bridges that to non-optional [RemotePostTag] and traps at the closure boundary.

Fix

  • Coalesce the two map helpers to @[] (… ?: @[]). A missing tag/category list semantically is empty, so the _Nonnull block contract stays true for every current and future caller. This covers all six tag/category fetch entry points at once (getTags*, searchTagsWithName:, getCategories*, searchCategoriesWithName:).

Test plan

  • The WordPressKitObjC module builds via the WordPress app build (generic iOS Simulator).
  • Tag and category lists still load for a .com site.

Part of the Objective-C non-null nullability audit; see #25964.

@jkmassel jkmassel added this to the 27.3 milestone Sep 1, 2026
@jkmassel jkmassel self-assigned this Sep 1, 2026
@wpmobilebot

wpmobilebot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number34125
VersionPR #25969
Bundle IDorg.wordpress.alpha
Commit50d24ca
Installation URL57js9e4ilv0ig
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number34125
VersionPR #25969
Bundle IDcom.jetpack.alpha
Commit50d24ca
Installation URL6d94raluft0qg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jkmassel
jkmassel requested a review from crazytonyli September 1, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants