Files
shopPRO/.paul/phases/14-custom-fields-delete-bug/14-01-SUMMARY.md
Jacek 1ef6dc9092 fix: Custom fields delete bug — usunięcie wszystkich pól produktu nie działało
Dodano hidden marker custom_field_name_present w formularzu edycji produktu.
Zmieniono warunek w ProductRepository z array_key_exists('custom_field_name')
na array_key_exists('custom_field_name_present') — jQuery .serialize() pomijał
klucz pustej tablicy gdy wszystkie pola usunięte. Test jednostkowy dodany.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:51:57 +02:00

2.9 KiB

phase, plan, subsystem, tags, requires, provides, affects, tech-stack, key-files, key-decisions, patterns-established, duration, completed
phase plan subsystem tags requires provides affects tech-stack key-files key-decisions patterns-established duration completed
14-custom-fields-delete-bug 01 admin
custom-fields
product-edit
form-serialize
hidden-field
Fix usuwania wszystkich custom fields z produktu
added patterns
hidden marker field for form section detection
created modified
autoload/admin/Controllers/ShopProductController.php
autoload/Domain/Product/ProductRepository.php
tests/Unit/Domain/Product/ProductRepositoryTest.php
Hidden marker custom_field_name_present zamiast polegania na obecności custom_field_name[] w POST
Marker hidden field pattern: gdy sekcja formularza może mieć 0 elementów, dodaj hidden marker żeby serwer wiedział że sekcja była renderowana
~10min 2026-04-16

Phase 14 Plan 01: Custom fields delete bug fix — Summary

Naprawiono bug uniemożliwiający usunięcie wszystkich dodatkowych pól produktu — hidden marker gwarantuje wywołanie saveCustomFields() niezależnie od ilości pól.

Performance

Metric Value
Duration ~10min
Completed 2026-04-16
Tasks 2 completed
Files modified 3

Acceptance Criteria Results

Criterion Status Notes
AC-1: Usunięcie wszystkich custom fields Pass saveCustomFields() wywoływany dzięki markerowi, else branch kasuje wszystkie rekordy
AC-2: Częściowe usunięcie nadal działa Pass Logika saveCustomFields() dla niepustych list bez zmian
AC-3: Dodawanie pól nadal działa Pass Marker nie wpływa na insert/update path

Accomplishments

  • Dodano hidden field custom_field_name_present w renderCustomFieldsBox() — zawsze obecny w POST
  • Zmieniono warunek w ProductRepository:1339 z custom_field_name na custom_field_name_present
  • Dodano test jednostkowy potwierdzający delete all path (821 testów, 0 regresji)

Files Created/Modified

File Change Purpose
autoload/admin/Controllers/ShopProductController.php Modified Hidden marker custom_field_name_present w renderCustomFieldsBox()
autoload/Domain/Product/ProductRepository.php Modified Warunek zmieniony na sprawdzanie markera
tests/Unit/Domain/Product/ProductRepositoryTest.php Modified Test testSaveCustomFieldsDeletesAllWhenEmpty

Decisions Made

Decision Rationale Impact
Hidden marker zamiast wysyłania pustego array jQuery .serialize() pomija puste pola array — marker jest niezawodny Backward compat z API partial update (brak markera = skip)

Deviations from Plan

None — plan executed exactly as written.

Issues Encountered

None.

Next Phase Readiness

Ready:

  • Bug naprawiony, test przechodzi, zero regresji

Concerns:

  • None

Blockers:

  • None

Phase: 14-custom-fields-delete-bug, Plan: 01 Completed: 2026-04-16