fix: do not clear card color when update omits the field#8151
fix: do not clear card color when update omits the field#8151Lightshadow02 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>
89761fc to
f72ec66
Compare
|
Just a note on the two red checks here: they look like the known-flaky Cypress e2e suite rather than a regression from this PR. The same workflow currently fails on The change itself is backend-only and covered by four unit tests (color kept when the field is omitted / cleared on explicit null / cleared on empty string / set from a hex value). Happy to rebase or re-run anything if that helps. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
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