fix: do not clear card color when update omits the field#8151
Open
Lightshadow02 wants to merge 1 commit into
Open
fix: do not clear card color when update omits the field#8151Lightshadow02 wants to merge 1 commit into
Lightshadow02 wants to merge 1 commit into
Conversation
Fixes nextcloud#8131 Signed-off-by: HUGO LOUREIRO <149155946+Lightshadow02@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
luka-nextcloud
approved these changes
Jul 10, 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.
Summary
CardService::update()unconditionally called$card->setColor($color), so any API client that omits thecolorfield on a card update (mobile clients, scripts, integrations) silently wiped the stored card color.This applies the exact mechanism already used for the
donefield: the controllers build anOptionalNullableValueonly when the request body actually contains acolorkey (array_key_exists), and the service only touches the color when the wrapper is present:nullor""→ color clearedThe service guards with
is_string(), so malformed non-scalar payloads (e.g. an array) are treated as "clear" instead of being string-cast. Note: an unquoted numeric JSON value ("color": 123456), which previously coerced to the string"123456", now also clears — strings are the documented type for this field.The web frontend always sends the full card object including
color, so UI behaviour is unchanged. Covered by four new PHPUnit cases (kept / cleared via null / cleared via empty string / set).How to test
PUT /index.php/apps/deck/cards/{cardId}with a body that contains title/stackId/type/order but nocolorkey"color": nullstill clears it.Checklist
🤖 Generated with Claude Code