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 EditPostActivty onPostUploaded #20954

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

zwarm
Copy link
Contributor

@zwarm zwarm commented Jun 7, 2024

Fixes #20953

This PR addresses a potential NullPointerException in the onPostUploaded event handler by ensuring that the editPostRepository.id is safely accessed. In EditPostActivity, the EventBus is registered before EditPostRepository is fully initialized. As such, there is a risk that an onPostUploaded event might be posted before the EditPostRepository has completed its initialization process, thus causing an NPE when "id" is accessed.

Changes:

  • Updated the onPostUploaded method to use val editPostId = editPostRepository.getPost()?.id.
    This ensures that the check post.id == editPostId will fail if editPostRepository.getPost() returns null, preventing a NullPointerException.

To Test:

As I was unable to recreate the issue, please validate that the Create/Edit post flow works as expected.


Regression Notes

  1. Potential unintended areas of impact
    The crash still occurs

  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)
    N/A


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): N/A

@zwarm zwarm added this to the 25.0 ❄️ milestone Jun 7, 2024
@zwarm zwarm requested a review from irfano June 7, 2024 14:49
@zwarm zwarm self-assigned this Jun 7, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Jun 7, 2024

1 Warning
⚠️ This PR is assigned to the milestone 25.0 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 7, 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
Versionpr20954-08efcdc
Commit08efcdc
Direct Downloadwordpress-prototype-build-pr20954-08efcdc.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 7, 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
Versionpr20954-08efcdc
Commit08efcdc
Direct Downloadjetpack-prototype-build-pr20954-08efcdc.apk
Note: Google Login is not supported on these builds.

Copy link

sonarcloud bot commented Jun 7, 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

@zwarm zwarm merged commit 5ce39e0 into release/25.0 Jun 7, 2024
20 checks passed
@zwarm zwarm deleted the issue/20953-fix-NPE-onPostUploaded branch June 7, 2024 16:06
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.

4 participants