Commit 13193a251d8 for woocommerce
commit 13193a251d89001d6fdf404def9400582031a494
Author: James Kemp <me@jckemp.com>
Date: Fri Apr 17 13:30:20 2026 +0100
Fix DB update note not reappearing after dismissal (#63657)
* Fix DB update note not reappearing after dismissal
When a user dismisses the WC Admin DB update banner, it is soft-deleted
(is_deleted = 1). On subsequent updates, the note failed to reappear
because update_needed_notice() would early-return for the soft-deleted
note and never reset is_deleted.
This adds is_deleted checks and resets across all three notice update
methods so the note correctly reappears when a new DB migration is
needed.
Closes #56321
* Add changelog entry for DB update note fix
---------
Co-authored-by: Panos (Panagiotis Synetos) <2484390+PanosSynetos@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/fix-wooplug-3402-db-update-note-reappear b/plugins/woocommerce/changelog/fix-wooplug-3402-db-update-note-reappear
new file mode 100644
index 00000000000..892a2d96d53
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-wooplug-3402-db-update-note-reappear
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix DB update admin note not reappearing after being dismissed by the user.
diff --git a/plugins/woocommerce/includes/admin/notes/class-wc-notes-run-db-update.php b/plugins/woocommerce/includes/admin/notes/class-wc-notes-run-db-update.php
index 834f261e3df..1536b3bd75b 100644
--- a/plugins/woocommerce/includes/admin/notes/class-wc-notes-run-db-update.php
+++ b/plugins/woocommerce/includes/admin/notes/class-wc-notes-run-db-update.php
@@ -168,7 +168,7 @@ class WC_Notes_Run_Db_Update {
);
// Check if the note needs to be updated (e.g. expired nonce or different note type stored in the previous run).
- if ( Note::E_WC_ADMIN_NOTE_UNACTIONED === $note->get_status() && self::note_up_to_date( $note, $update_url, wp_list_pluck( $note_actions, 'name' ) ) ) {
+ if ( ! $note->get_is_deleted() && Note::E_WC_ADMIN_NOTE_UNACTIONED === $note->get_status() && self::note_up_to_date( $note, $update_url, wp_list_pluck( $note_actions, 'name' ) ) ) {
return $note;
}
@@ -185,6 +185,7 @@ class WC_Notes_Run_Db_Update {
// In case db version is out of sync with WC version or during the next update, the notice needs to show up again,
// so set it to unactioned.
$note->set_status( Note::E_WC_ADMIN_NOTE_UNACTIONED );
+ $note->set_is_deleted( false );
// Set new actions.
$note->clear_actions();
@@ -215,6 +216,8 @@ class WC_Notes_Run_Db_Update {
$note->set_title( __( 'WooCommerce database update in progress', 'woocommerce' ) );
$note->set_content( __( 'WooCommerce is updating the database in the background. The database update process may take a little while, so please be patient.', 'woocommerce' ) );
+ $note->set_is_deleted( false );
+
$note->clear_actions();
$note->add_action(
'update-db_see-progress',
@@ -264,6 +267,8 @@ class WC_Notes_Run_Db_Update {
$note->set_title( __( 'WooCommerce database update done', 'woocommerce' ) );
$note->set_content( __( 'WooCommerce database update complete. Thank you for updating to the latest version!', 'woocommerce' ) );
+ $note->set_is_deleted( false );
+
$note->clear_actions();
foreach ( $note_actions as $note_action ) {
$note->add_action( ...array_values( $note_action ) );
diff --git a/plugins/woocommerce/tests/legacy/unit-tests/admin/notes/class-wc-tests-notes-run-db-update.php b/plugins/woocommerce/tests/legacy/unit-tests/admin/notes/class-wc-tests-notes-run-db-update.php
index da682204e80..bf1d0d2eccc 100644
--- a/plugins/woocommerce/tests/legacy/unit-tests/admin/notes/class-wc-tests-notes-run-db-update.php
+++ b/plugins/woocommerce/tests/legacy/unit-tests/admin/notes/class-wc-tests-notes-run-db-update.php
@@ -161,6 +161,46 @@ class WC_Tests_Notes_Run_Db_Update extends WC_Unit_Test_Case {
}
+ /**
+ * @testdox Soft-deleted db update note should reappear when a new update is needed.
+ */
+ public function test_soft_deleted_note_reappears_on_new_update() {
+ // Make it appear as if db version is lower than WC version, i.e. db update is required.
+ update_option( 'woocommerce_db_version', '3.9.0' );
+
+ // The legacy 'update' notice must be present for maybe_update_notice() to proceed.
+ \WC_Admin_Notices::add_notice( 'update' );
+
+ WC_Notes_Run_Db_Update::add_notice();
+
+ $note_ids = self::get_db_update_notes();
+ $this->assertEquals( 1, count( $note_ids ), 'A db update note should be created.' );
+
+ // Soft-delete the note (simulates user clicking X to dismiss).
+ $note = new Note( $note_ids[0] );
+ $note->set_is_deleted( true );
+ $note->save();
+
+ // Verify it's soft-deleted.
+ $note = new Note( $note_ids[0] );
+ $this->assertTrue( (bool) $note->get_is_deleted(), 'Note should be soft-deleted.' );
+
+ // Simulate a new update needed by calling add_notice again.
+ WC_Notes_Run_Db_Update::add_notice();
+
+ // Verify the note is no longer soft-deleted.
+ $note = new Note( $note_ids[0] );
+ $this->assertFalse( (bool) $note->get_is_deleted(), 'Soft-deleted note should be un-deleted when a new update is needed.' );
+ $this->assertEquals( Note::E_WC_ADMIN_NOTE_UNACTIONED, $note->get_status(), 'Note should be set back to unactioned.' );
+
+ $actions = $note->get_actions();
+ $this->assertEquals( 'update-db_run', $actions[0]->name, 'Note should show the update database action.' );
+
+ // Clean up.
+ \WC_Install::update_db_version();
+ \WC_Admin_Notices::remove_notice( 'update' );
+ }
+
/**
* Test switch from db update needed to thanks note.
*/