Skip to content

Report an update that changed nothing instead of reporting success - #719

Merged
blaipr merged 1 commit into
mainfrom
fix/update-reports-when-nothing-changed
Aug 13, 2026
Merged

Report an update that changed nothing instead of reporting success#719
blaipr merged 1 commit into
mainfrom
fix/update-reports-when-nothing-changed

Conversation

@blaipr

@blaipr blaipr commented Aug 13, 2026

Copy link
Copy Markdown
Member

The bug

Six services handed the caller success for an update whose WHERE matched no rows:

service answered
Category Category updated
Client Client updated
Tag Tag updated
UserGroup Group updated
ItemPreset Permission updated
AuthToken Authorization updated

Editing one of these after it had been deleted — from another session, or another administrator's window — reported the change as saved. The row was gone, nothing was written, and the person editing it had no way to know.

Every one of those repositories already counts the affected rows, and AuthTokenRepository::update() goes as far as returning getAffectedNumRows() === 1 for exactly this purpose — which the service dropped on the floor.

UserProfileService::update() has always made the check. This is the same check, in the five places it was missing and the one where it was computed and ignored.

Details worth knowing

  • The group's check sits inside its transaction, so a failed update does not write the members either.
  • Each message reuses the string its own repository already carries (Error while updating the category, …), so nothing needs translating; the authorisation one reuses Token not found, which is what its API answers elsewhere for the same situation.

Five tests pinned the old answer

The four API edit a nonexistent id cases and the web one — which said in as many words that this was "asymmetric with the profile side". They now assert the refusal. The group service also gains a unit test: an update of a group that is not there raises, and the members are never touched.

Testing

Both suites green: 3062 unit, 821 integration. PHPStan and PHPCS clean.

Six services handed the caller success for an update whose WHERE matched no
rows. Editing a category, client, tag, group, preset or authorisation that had
been deleted in the meantime answered "updated" — the row was gone, nothing was
written, and whoever was editing it was told their change had been saved.

Every one of those repositories already counts the affected rows, and the
authorisation one goes as far as returning a boolean for exactly this purpose,
which the service dropped. UserProfile has always made the check; this is the
same check, in the five places it was missing and the one where it was computed
and ignored.

The group's check is inside its transaction, so the members are not written
either.

Five tests pinned the old answer as correct — the four API edit-nonexistent
cases and the web one, which said in as many words that this was asymmetric with
the profile side. They now assert the refusal, and the group service gains a
unit test for it.
@blaipr
blaipr merged commit 2aa91d5 into main Aug 13, 2026
8 checks passed
@blaipr
blaipr deleted the fix/update-reports-when-nothing-changed branch August 13, 2026 17:21
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