Skip to content

[Web] update modified timestamp when tags change - #7377

Open
smpaz7467 wants to merge 1 commit into
mailcow:stagingfrom
smpaz7467:fix/tag-changes-modified-timestamp
Open

[Web] update modified timestamp when tags change#7377
smpaz7467 wants to merge 1 commit into
mailcow:stagingfrom
smpaz7467:fix/tag-changes-modified-timestamp

Conversation

@smpaz7467

Copy link
Copy Markdown
Contributor

Description

Adding or removing a tag on a domain or mailbox never updated the Last modified timestamp shown in the UI.

Tags live in the separate tags_domain / tags_mailbox tables, so a tag change never writes to the domain / mailbox row itself. Since modified is declared DATETIME ON UPDATE CURRENT_TIMESTAMP, it only advances when that row is actually written.

On the domain edit path the surrounding statement only writes description and gal:

UPDATE `domain` SET `description` = :description, `gal` = :gal WHERE `domain` = :domain

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 modified explicitly whenever a tag row was actually inserted or deleted. The rowCount() 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/tag endpoints.

Verification

On a live stack, reading modified straight from MariaDB:

action before after
add domain tag unchanged (14:05:10 stayed 14:05:10) bumped
add mailbox tag unchanged bumped
delete domain tag unchanged bumped (14:05:1014:06:14)
delete mailbox tag unchanged bumped (14:05:1414:06:19)
delete a tag that does not exist unchanged unchanged (no false bump)

A normal description edit still bumps the timestamp exactly as before.

Fixes #6931

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant