[Web] update modified timestamp when tags change - #7377
Open
smpaz7467 wants to merge 1 commit into
Open
Conversation
Tags for domains and mailboxes live in the separate `tags_domain` and `tags_mailbox` tables. Adding or removing a tag therefore never writes to the `domain` / `mailbox` row itself, so the `modified` column - which is declared `DATETIME ON UPDATE CURRENT_TIMESTAMP` - is never triggered. On the domain edit path the surrounding UPDATE only writes `description` and `gal`; when just a tag changed those values are unchanged, so MariaDB skips the row write entirely and `modified` keeps its old value. The same applies to mailbox tags and to both tag deletion paths. Bump `modified` explicitly whenever a tag row was actually inserted or deleted (checked via rowCount, so a no-op tag save does not touch the timestamp). Fixes mailcow#6931
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.
Description
Adding or removing a tag on a domain or mailbox never updated the
Last modifiedtimestamp shown in the UI.Tags live in the separate
tags_domain/tags_mailboxtables, so a tag change never writes to thedomain/mailboxrow itself. Sincemodifiedis declaredDATETIME ON UPDATE CURRENT_TIMESTAMP, it only advances when that row is actually written.On the domain edit path the surrounding statement only writes
descriptionandgal:When only a tag changed, those values are identical to what is already stored, so MariaDB skips the row write entirely and the ON UPDATE clause never fires. The same applies to mailbox tags and to both tag deletion paths.
This bumps
modifiedexplicitly whenever a tag row was actually inserted or deleted. TherowCount()check keeps it precise: re-saving a tag that already exists, or deleting one that is not there, still leaves the timestamp untouched.Covers all five paths: domain edit (domain-admin and admin branches), mailbox edit, and the
delete/domain/tag+delete/mailbox/tagendpoints.Verification
On a live stack, reading
modifiedstraight from MariaDB:14:05:10stayed14:05:10)14:05:10→14:06:14)14:05:14→14:06:19)A normal description edit still bumps the timestamp exactly as before.
Fixes #6931