-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix: Null Pointer Exception in PublishSettingsViewModel #20745
Conversation
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #20745 +/- ##
=======================================
Coverage 40.62% 40.62%
=======================================
Files 1489 1489
Lines 68531 68532 +1
Branches 11326 11326
=======================================
+ Hits 27841 27842 +1
Misses 38161 38161
Partials 2529 2529 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quality Gate passedIssues Measures |
Fixes #20272
This PR fixes a NPE when accessing
EditPostRepository.dateCreated
. The getter fordateCreated
uses apost!!
which will throw a NPE if the post is null. This PR replaces the use oflet
withtakeIf { it.hasPost() }
to ensure we don't call dateCreated when there is no post.To Test:
I was unable to recreate the issue, but did write a unit test to validate the new
takeIf
logic.Please verify that all unit tests pass CI
Regression Notes
Potential unintended areas of impact
Continue to experience the NPE crash
What I did to test those areas of impact (or what existing automated tests I relied on)
Add unit test to
EditPostPublishSettingsViewModelTest
What automated tests I added (or what prevented me from doing so)
N/A
PR Submission Checklist:
RELEASE-NOTES.txt
if necessary.Testing Checklist (strike-out the not-applying and unnecessary ones): N/A