Skip to content

Load the current Core Data model once per process#25728

Open
crazytonyli wants to merge 2 commits into
trunkfrom
task/fix-duplicated-core-data-symbol
Open

Load the current Core Data model once per process#25728
crazytonyli wants to merge 2 commits into
trunkfrom
task/fix-duplicated-core-data-symbol

Conversation

@crazytonyli

Copy link
Copy Markdown
Contributor

We have a long-running issue of the Core Data model being created multiple times for each ContextManager.forTesting instance, which sometimes causes unit test flakiness. This PR fixes that issue by holding the current model in a static property.

The changes should not have any impact on the app, which uses ContextManager singleton.

Each ContextManager instance used to load its own NSManagedObjectModel from
WordPress.momd. Every loaded model registers its entities in Core Data's
process-global class-to-entity table, so in unit tests (where each test
creates a ContextManager) identical models accumulated and +entity could not
disambiguate them. The current model is now cached in a static and shared by
all instances, while versioned models for migrations still load per request.
@crazytonyli crazytonyli added this to the 27.1 milestone Jul 2, 2026
@crazytonyli crazytonyli requested a review from jkmassel July 2, 2026 01:00
@crazytonyli crazytonyli enabled auto-merge July 2, 2026 01:01
@wpmobilebot

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 Number32964
VersionPR #25728
Bundle IDorg.wordpress.alpha
Commit39736ba
Installation URL7t10fhrbh9etg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

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 Number32964
VersionPR #25728
Bundle IDcom.jetpack.alpha
Commit39736ba
Installation URL16inn96gct120
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

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