Fix NPE in Site Settings
Fixes #20840
This PR fixes a crash in SiteSettingsFragment where mBloggingRemindersViewModel.onBlogSettingsItemClicked() is called on a null object.
To Test:
I haven't been able to reproduce this crash, so code review + smoke test My Site -> Site Settings -> Blogging -> Reminders.
Regression Notes
-
Potential unintended areas of impact
- None
-
What I did to test those areas of impact (or what existing automated tests I relied on)
- None
-
What automated tests I added (or what prevented me from doing so)
- None
PR Submission Checklist:
- [x] I have completed the Regression Notes.
- [x] I have considered adding accessibility improvements for my changes.
- [x] I have considered if this change warrants user-facing release notes and have added them to
RELEASE-NOTES.txtif necessary.
Testing Checklist (strike-out the not-applying and unnecessary ones):
- [ ] ~WordPress.com sites and self-hosted Jetpack sites.~
- [ ] ~Portrait and landscape orientations.~
- [ ] ~Light and dark modes.~
- [ ] ~Fonts: Larger, smaller and bold text.~
- [ ] ~High contrast.~
- [ ] ~Talkback.~
- [ ] ~Languages with large words or with letters/accents not frequently used in English.~
- [ ] ~Right-to-left languages. (Even if translation isnβt complete, formatting should still respect the right-to-left layout)~
- [ ] ~Large and small screen sizes. (Tablet and smaller phones)~
- [ ] ~Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)~
π² You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
| App Name | WordPress |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr20845-421e2df | |
| Commit | 421e2dfce5ab87003a6f35918610ae3706bedaf2 | |
| Direct Download | wordpress-prototype-build-pr20845-421e2df.apk |
π² You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
| App Name | Jetpack |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr20845-421e2df | |
| Commit | 421e2dfce5ab87003a6f35918610ae3706bedaf2 | |
| Direct Download | jetpack-prototype-build-pr20845-421e2df.apk |
site is already being checked in onCreate and the activity is finished if the site is null.
The crash message is Attempt to invoke virtual method 'void org.wordpress.android.ui.bloggingreminders.BloggingRemindersViewModel.onBlogSettingsItemClicked(int)' on a null object reference. From the logs, I understand that the null object is BloggingRemindersViewModel, not site. Can you confirm?
Hi @irfano thanks for taking a look π
site is already being checked in onCreate and the activity is finished if the site is null.
From what I understand, mSite can become null after onCreate is called (deletion or removal of a site) which is why a few other functions in this class are also doing a null check. I personally feel that it's safer to have than not, but open to discussion.
From the logs, I understand that the null object is BloggingRemindersViewModel, not site.
Good point, thank you for catching that! I've added a null check for BloggingRemindersViewModel as well to address the case where it isn't initialized. What do you think?
Thanks @irfano, I updated the release notes π For future reference, how do we decide which bug/crash fixes to include there? I noticed a few other crash fixes didn't update this file.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
For future reference, how do we decide which bug/crash fixes to include there?
I usually add every change that affects users to release notes, but if it's a minor change, with * indicator. More detail:
- pbMoDN-o4-p2
- pdcxQM-Km-p2
Awesome, thank for you sharing!