fix(api): preserve null in Manager API payload field updates (#289)#295
Open
Ibochkarev wants to merge 1 commit into
Open
fix(api): preserve null in Manager API payload field updates (#289)#295Ibochkarev wants to merge 1 commit into
Ibochkarev wants to merge 1 commit into
Conversation
Replace isset with array_key_exists so cleared PrimeVue InputNumber fields and explicit null values reach xPDO set() instead of leaving stale DB data.
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.
Описание
В Manager API при whitelisted-пробросе полей из payload использовался
isset($data[$field]), который возвращаетfalseдля значенияnull. PrimeVueInputNumberпри очистке поля отправляетnull, поэтому старое значение оставалось в БД (аналогичный баг уже исправлен вDeliveriesController/PaymentsController— PR #287).Заменено на
array_key_exists($field, $data)в подтверждённых местах и двух связанных сервисах с тем же антипаттерном. Неподтверждённые контроллеры из списка issue (#289) намеренно не тронуты, чтобы не плодить шум в diff.Изменённые файлы:
OrdersController— создание черновика (адрес) и обновление позиции заказа (price,weight, очисткаoptionsчерезnull)ExtraFieldsService— обновление метаданных extra fields из Manager APICustomerAddressManager— пересчёт hash при явной очистке адресных полей (nullв payload)Тип изменений
Связанные Issues
Closes #289
Как это было протестировано?
Конфигурация тестирования:
fix/289-null-payload-fieldsphp -lна изменённых PHP-файлахРекомендуемый сценарий ручной проверки:
priceилиweightвInputNumberи сохранить — значение должно сброситься (xPDO приведётnull→0для decimal).optionsдолжны обнулиться (getOptionsForSave()шлётnull).Скриншоты (если применимо)
Чеклист
Дополнительные заметки
Связанное исправление: PR #287 (
DeliveriesController/PaymentsController).Кандидаты из issue с низкой/средней вероятностью (
CustomerAddressesController,VendorsController,CustomersController,LinksController,StatusesController) сознательно исключены — в соответствующих Vue-формах преобладаютInputText/Checkbox, которые шлют''илиtrue/false, а неnull.