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>
This commit is contained in:
95
.paul/phases/14-custom-fields-delete-bug/14-01-SUMMARY.md
Normal file
95
.paul/phases/14-custom-fields-delete-bug/14-01-SUMMARY.md
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
phase: 14-custom-fields-delete-bug
|
||||
plan: 01
|
||||
subsystem: admin
|
||||
tags: [custom-fields, product-edit, form-serialize, hidden-field]
|
||||
|
||||
requires: []
|
||||
provides:
|
||||
- Fix usuwania wszystkich custom fields z produktu
|
||||
affects: []
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns: [hidden marker field for form section detection]
|
||||
|
||||
key-files:
|
||||
created: []
|
||||
modified:
|
||||
- autoload/admin/Controllers/ShopProductController.php
|
||||
- autoload/Domain/Product/ProductRepository.php
|
||||
- tests/Unit/Domain/Product/ProductRepositoryTest.php
|
||||
|
||||
key-decisions:
|
||||
- "Hidden marker custom_field_name_present zamiast polegania na obecności custom_field_name[] w POST"
|
||||
|
||||
patterns-established:
|
||||
- "Marker hidden field pattern: gdy sekcja formularza może mieć 0 elementów, dodaj hidden marker żeby serwer wiedział że sekcja była renderowana"
|
||||
|
||||
duration: ~10min
|
||||
completed: 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*
|
||||
Reference in New Issue
Block a user