fix: cancel scheduled notification when reverting a post to draft.#427
Merged
sherwinski merged 4 commits intoJun 24, 2026
Merged
Conversation
…date version to 3.9.1
Contributor
|
Thanks @marclucraft, let me give this a test locally and review before moving to merge. |
sherwinski
reviewed
Jun 24, 2026
sherwinski
reviewed
Jun 24, 2026
…l_and_clear_notification The handler was renamed from onesignal_cancel_notification_on_post_delete but the hook-registration test still referenced the old name, making the assertion self-referential and decoupled from the production registration.
…rt branch The elseif already follows the publish/future branch, so new_status can never be publish or future here; the extra checks were dead.
Keep version metadata and changelog updates to a dedicated release PR.
sherwinski
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One Line Summary
fix: Cancel scheduled notification when reverting a post to draft. Updated version to 3.9.1
Motivation
Customer follow up via Support
Previously, reverting a scheduled post to Draft or Pending Review left the
corresponding OneSignal notification queued — it would still fire at the
original scheduled time even though the post was no longer going to publish.
Scope
futurestatus) that are reverted to Draft orPending Review before their publish time.
changed via quick-edit (existing behaviour unchanged), post deletion/trash,
v2 legacy code, JS/CSS behaviour, any other status transitions.
Testing
Manual
notification, and save as Scheduled.
correct send time.
push is delivered at the original scheduled time.
(regression check on the shared helper).
re-creates the notification (regression).
Test in both Classic editor and Block (Gutenberg) editor.
WordPress 6.x+, PHP 7.4+.
Unit / Integration
Three new integration tests added to
tests/integration/TestAPIIntegration.php:test_cancel_notification_when_scheduled_post_reverts_to_draft— verifies theDELETE API call is made and post meta is cleared on a
future → drafttransition.test_no_cancellation_when_no_notification_stored_on_draft_revert— verifiesno HTTP request is made when there is no stored notification ID.
test_no_cancellation_for_disallowed_post_type_on_draft_revert— verifies thepost-type guard prevents cancellation for unregistered post types.
composer testpasses locallyAffected code checklist
v3/)v2/legacy codereadme.txt, etc.)Checklist
readme.txtand plugin version bumped if user-facing (release PRs only)