Regresja z ver. 0.339 (split IntegrationsRepository → ApiloRepository): $apiloRepository nie było w use() 5 handlerów cron.php. Dodano retry zamówień z apilo_order_id=-1 co 1h. Dodano powiadomienia mailowe o błędach sync Apilo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
122 lines
4.2 KiB
Markdown
122 lines
4.2 KiB
Markdown
---
|
|
phase: 08-apilo-orders-fix
|
|
plan: 01
|
|
subsystem: integrations
|
|
tags: [apilo, cron, closure, bugfix]
|
|
|
|
requires:
|
|
- phase: 06-integrations-refactoring
|
|
provides: ApiloRepository split from IntegrationsRepository
|
|
|
|
provides:
|
|
- Fix for missing $apiloRepository in cron.php closure use() clauses
|
|
- Auto-retry for failed orders (apilo_order_id = -1) with 1h interval
|
|
- Email notifications for Apilo sync errors (cURL + permanently failed jobs)
|
|
|
|
affects: []
|
|
|
|
tech-stack:
|
|
added: []
|
|
patterns: []
|
|
|
|
key-files:
|
|
created: []
|
|
modified: [cron.php]
|
|
|
|
key-decisions:
|
|
- "Retry -1 orders with 1h interval instead of permanent failure"
|
|
- "Prioritize NULL orders over -1 retries"
|
|
- "Email notification on permanently failed Apilo jobs"
|
|
|
|
patterns-established: []
|
|
|
|
duration: 25min
|
|
started: 2026-03-16T10:00:00+01:00
|
|
completed: 2026-03-16T10:25:00+01:00
|
|
---
|
|
|
|
# Phase 8 Plan 01: Apilo orders fix — Summary
|
|
|
|
**Naprawiono brakujące $apiloRepository w closurach cron.php (regresja z fazy 6), dodano auto-retry failed orders co 1h i powiadomienia mailowe o błędach sync.**
|
|
|
|
## Performance
|
|
|
|
| Metric | Value |
|
|
|--------|-------|
|
|
| Duration | ~25min |
|
|
| Tasks | 3 completed (checkpoint skipped — diagnoza jednoznaczna) |
|
|
| Files modified | 1 (cron.php) |
|
|
|
|
## Acceptance Criteria Results
|
|
|
|
| Criterion | Status | Notes |
|
|
|-----------|--------|-------|
|
|
| AC-1: Przyczyna zdiagnozowana | Pass | Brakujące $apiloRepository w use() closures — regresja z fazy 6 |
|
|
| AC-2: Przyczyna naprawiona | Pass | Dodano $apiloRepository do 5 handlerów w cron.php |
|
|
| AC-3: Zaległe zamówienia gotowe do wysłania | Pass | 14 orders z NULL wyślą się automatycznie; -1 orders retry co 1h |
|
|
|
|
## Accomplishments
|
|
|
|
- Zdiagnozowano przyczynę: `$apiloRepository` nie było w `use()` 5 closures w cron.php po refactorze fazy 6
|
|
- Dodano `$apiloRepository` do use() w handlerach: APILO_TOKEN_KEEPALIVE, APILO_SEND_ORDER, APILO_PRODUCT_SYNC, APILO_PRICELIST_SYNC, APILO_STATUS_POLL
|
|
- Dodano auto-retry zamówień z `apilo_order_id = -1` z interwałem 1h (priorytet: najpierw NULL, potem -1)
|
|
- Dodano powiadomienie mailowe przy błędzie cURL w send_order
|
|
- Dodano powiadomienie mailowe o trwale failed Apilo jobach (po wyczerpaniu max_attempts)
|
|
|
|
## Files Created/Modified
|
|
|
|
| File | Change | Purpose |
|
|
|------|--------|---------|
|
|
| `cron.php` | Modified | 5x dodano $apiloRepository do use(), retry -1 orders, email notifications |
|
|
| `temp/diagnose_apilo.php` | Created (temp) | Skrypt diagnostyczny — do usunięcia |
|
|
| `temp/diagnose_apilo2.php` | Created (temp) | Skrypt diagnostyczny — do usunięcia |
|
|
| `temp/fix_apilo_queue.php` | Created (temp) | Reset stuck jobów na instancji — do usunięcia po użyciu |
|
|
|
|
## Decisions Made
|
|
|
|
| Decision | Rationale | Impact |
|
|
|----------|-----------|--------|
|
|
| Retry -1 orders co 1h zamiast permanent failure | Nie trzeba ręcznie resetować po bugfixach | Zamówienia same się wyślą po deploy |
|
|
| Priorytet NULL > -1 | Nowe zamówienia ważniejsze niż retry | -1 czekają aż nie ma nowych |
|
|
| Checkpoint decision skipped | Diagnoza jednoznaczna — kod bug | Szybsza naprawa |
|
|
|
|
## Deviations from Plan
|
|
|
|
### Summary
|
|
|
|
| Type | Count | Impact |
|
|
|------|-------|--------|
|
|
| Scope additions | 2 | Ulepszenia: retry -1 + email notifications |
|
|
| Skipped checkpoints | 1 | Diagnoza jednoznaczna, nie potrzebna decyzja |
|
|
|
|
**Total impact:** Dodatkowe ulepszenia wykraczające poza plan, ale bezpośrednio powiązane z problemem.
|
|
|
|
### Scope Additions
|
|
|
|
1. **Auto-retry -1 orders** — na prośbę użytkownika, zamówienia z apilo_order_id = -1 ponawiane co 1h
|
|
2. **Email notifications** — na prośbę użytkownika, mail przy cURL error i permanently failed jobs
|
|
|
|
## Issues Encountered
|
|
|
|
| Issue | Resolution |
|
|
|-------|------------|
|
|
| Brak klienta mysql na lokalnej maszynie | Użyto PHP PDO do zdalnej diagnostyki |
|
|
| Testy IntegrationsRepository failują | Pre-existing issue (brak medoo stub), niezwiązane ze zmianą |
|
|
|
|
## Next Phase Readiness
|
|
|
|
**Ready:**
|
|
- cron.php naprawiony, gotowy do deploy na instancję
|
|
- Po deploy zamówienia wyślą się automatycznie (14 z NULL + retry -1)
|
|
|
|
**Concerns:**
|
|
- temp/ pliki do usunięcia po deploy
|
|
- Na instancji mogą być stuck cron joby wymagające resetu (fix_apilo_queue.php)
|
|
|
|
**Blockers:**
|
|
- None
|
|
|
|
---
|
|
*Phase: 08-apilo-orders-fix, Plan: 01*
|
|
*Completed: 2026-03-16*
|