Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UGC: Fix an edge case where the app could crash when blocking a post author #20421

Merged
merged 2 commits into from
Mar 28, 2023

Conversation

salimbraksa
Copy link
Contributor

@salimbraksa salimbraksa commented Mar 27, 2023

Fixes #20387

This PR resolves an issue where the app could crash when blocking a Post Author.

Root Cause

  1. Part of the User Blocking implementation is to read the post.authorID to check whether it's blocked or not.
  2. The type of post.authorID is NSNumber!
  3. The code accessed post.authorID without safely unwrapping it. ( I thought authorID property would never be nil )
  4. There is a case where post.authorID could be nil I don't know how to reproduce that case, though.

Solution
Safely unwrap that property before using it.

guard let authorID = post.authorID else {
    return true
}
// Use authorID

Test Instructions

I don't know how to reproduce a case where post.authorID is nil but I think we should test User Blocking feature for regression.

Since the code changes are minor and are unlikely to cause a regression issue, feel free to test only 1 one of the following use cases:

User Blocking Test Instructions

Regression Notes

  1. Potential unintended areas of impact
    Smoke test User Blocking feature.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual testing.

  3. What automated tests I added (or what prevented me from doing so)
    None.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@salimbraksa salimbraksa added this to the 22.0 ❄️ milestone Mar 27, 2023
@salimbraksa salimbraksa self-assigned this Mar 27, 2023
@salimbraksa salimbraksa changed the base branch from trunk to release/22.0 March 27, 2023 21:32
@salimbraksa salimbraksa marked this pull request as ready for review March 27, 2023 22:09
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Mar 27, 2023

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 4 days Please, make sure to get it merged by then or assign it to a later expiring milestone
⚠️

This PR contains changes to RELEASE_NOTES.txt.
Note that these changes won't affect the final version of the release notes as this version is in code freeze.
Please, get in touch with a release manager if you want to update the final release notes.

Generated by 🚫 dangerJS

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 27, 2023

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr20421-3450b7d
Version22.0
Bundle IDorg.wordpress.alpha
Commit3450b7d
App Center BuildWPiOS - One-Offs #5340
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 27, 2023

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr20421-3450b7d
Version22.0
Bundle IDcom.jetpack.alpha
Commit3450b7d
App Center Buildjetpack-installable-builds #4367
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@alpavanoglu alpavanoglu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to look into a way to write a unit test for this.

@mokagio mokagio merged commit 53b7fbe into release/22.0 Mar 28, 2023
@mokagio mokagio deleted the task/20387-user-blocking-crash branch March 28, 2023 22:12
@mokagio mokagio mentioned this pull request Mar 29, 2023
4 tasks
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.

EXC_BREAKPOINT: authorID
4 participants