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

Fix NPE in Site Settings #20845

Merged
merged 4 commits into from
May 22, 2024
Merged

Fix NPE in Site Settings #20845

merged 4 commits into from
May 22, 2024

Conversation

aditi-bhatia
Copy link
Contributor

@aditi-bhatia aditi-bhatia commented May 18, 2024

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

  1. Potential unintended areas of impact

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

    • None
  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 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.

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)

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 18, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20845-421e2df
Commit421e2df
Direct Downloadwordpress-prototype-build-pr20845-421e2df.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 18, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20845-421e2df
Commit421e2df
Direct Downloadjetpack-prototype-build-pr20845-421e2df.apk
Note: Google Login is not supported on these builds.

@irfano
Copy link
Member

irfano commented May 20, 2024

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?

@aditi-bhatia
Copy link
Contributor Author

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?

Copy link
Member

@irfano irfano left a comment

Choose a reason for hiding this comment

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

I personally feel that it's safer to have than not

I agree!
LGTM! 👍🏻 I'm not merging since you may want to add this fix to RELEASE-NOTES.

@aditi-bhatia
Copy link
Contributor Author

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.

Copy link

sonarcloud bot commented May 21, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@aditi-bhatia aditi-bhatia merged commit 0f7f65b into trunk May 22, 2024
20 checks passed
@aditi-bhatia aditi-bhatia deleted the issue/20840-NPE branch May 22, 2024 00:02
@irfano
Copy link
Member

irfano commented May 22, 2024

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

@aditi-bhatia
Copy link
Contributor Author

Awesome, thank for you sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants