wordpress-mobile / wordpress-mobile/WordPress-iOS

ReaderPost performs double-save on the ContextManager when saved

Open
#19,771 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Type] Tech Debt Reader
Dominant language
Swift
Stars
3.9k
Forks
1.2k
Avg merge
23h 51m
Merged PRs (30d)
58

Description

Refs https://github.com/wordpress-mobile/WordPress-iOS/pull/19765#issuecomment-1345181064

Currently, when saving a post in the Reader, a didSave hook is implemented on ReaderPost to update the parent object, ReaderCard:

https://github.com/wordpress-mobile/WordPress-iOS/blob/be75d66eccf451ced90efe45a8ba658131f865d0/WordPress/Classes/Models/ReaderPost.m#L513-L522

As quoted above, the didSave method made another save call to ContextManager, effectively double-saving every time a post is saved. This can make Core Data operations slightly less visible, and might introduce side effects (i.e., the issue described in #19765). As an idea, we can look into moving this part of the logic to the post-saving logic described in https://github.com/wordpress-mobile/WordPress-iOS/pull/19765#pullrequestreview-1212232664.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in WordPress/Classes/Models/ReaderPost.m around lines 513-522 and inspect the didSave hook, then read the post-saving logic discussed in PR #19765. Trace how ReaderPost updates its parent ReaderCard and calls ContextManager. Done means saving a ReaderPost no longer causes a second ContextManager save while the parent update still occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c
Domain
database, mobile
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.