diff --git a/docs/bugs-and-fixes.md b/docs/bugs-and-fixes.md index b47843c..d93b94e 100644 --- a/docs/bugs-and-fixes.md +++ b/docs/bugs-and-fixes.md @@ -33,7 +33,7 @@ Wire cache-clear into the form process so it happens automatically on every succ 1. Create a small plugin `user/plugins/cache-on-save/` with one event listener: - Listen on `onFormProcessed` - - When the form name is `new-entry`, call `$this->grav['cache']->clear()` + - When the form name is `new-entry`, call `$this->grav['cache']->deleteAll()` (note: `clear()` does not exist on `Grav\Common\Cache` in Grav 1.7) 2. Enable the plugin in `user/config/plugins/cache-on-save.yaml` This is the cleanest approach: it fires exactly once per successful submission, requires no changes to `post-form.md`, and works for any future forms too. @@ -102,3 +102,35 @@ Acceptable for a single-user dev setup — eliminates both BUG-001's side-effect 2. Reload any page — no 500 error, template works immediately without manual cache flush --- + +## BUG-003 — One post per day limit; silent failure on duplicate date + +**Status:** fixed 2026-06-18 +**Reported:** 2026-06-18 + +### Symptom + +Submitting a second post with the same date as an existing entry shows "Entry posted successfully!" but creates no file. The user's post is silently discarded. + +### Root cause + +The `add-page-by-form` plugin built the page slug from date only (`Y-m-d`), producing folder names like `2026-06-18.entry`. With `overwrite_mode: false`, if that folder already exists the plugin skips page creation but does not abort — the `message` process step runs regardless, showing a false success. + +### Fix + +Change the slug template in `user/pages/02.post/post-form.md` to include time and title: + +```twig +{{ form.value.date|date('Y-m-d-Hi') }}-{{ form.value.title|lower|regex_replace('/[^a-z0-9]+/', '-')|trim('-') }} +``` + +Example: title "Arrived in Tokyo" at 14:30 on 2026-06-18 → `2026-06-18-1430-arrived-in-tokyo` + +The slug is locked at creation time. Renaming the title afterwards does not change the URL. + +### Acceptance criteria + +1. Submit two posts on the same day with different times or titles — both appear in `/tracker` as separate entries +2. Renaming a post's title in the frontmatter does not break its URL + +--- diff --git a/docs/qa-test-plan.md b/docs/qa-test-plan.md index 1116764..c94574e 100644 --- a/docs/qa-test-plan.md +++ b/docs/qa-test-plan.md @@ -336,6 +336,12 @@ These scenarios cover the full round-trip: filling the form → saving → verif | Longitude | `139.691711` | | Photos | none (keep simple for first run) | +**Expected slug:** `2026-06-18-1000-qa-test-entry` +**Expected folder:** `2026-06-18-1000-qa-test-entry.entry/` +**Expected URL:** `/tracker/2026-06-18-1000-qa-test-entry.entry` + +The slug is built from `date(Y-m-d-Hi)` + title lowercased with `[^a-z0-9]+` replaced by hyphens. + --- ### TC-P.1: Post form requires authentication @@ -405,8 +411,8 @@ These scenarios cover the full round-trip: filling the form → saving → verif | Step | Action | Expected Result | |---|---|---| | 1 | After TC-P.4 completes | — | -| 2 | Check directory `user/pages/01.tracker/` | Folder `2026-06-18.entry/` exists (add-page-by-form appends template name per `physical_template_name: true`) | -| 3 | Read `user/pages/01.tracker/2026-06-18.entry/entry.md` | File exists | +| 2 | Check directory `user/pages/01.tracker/` | Folder `2026-06-18-1000-qa-test-entry.entry/` exists (add-page-by-form appends template name per `physical_template_name: true`) | +| 3 | Read `user/pages/01.tracker/2026-06-18-1000-qa-test-entry.entry/entry.md` | File exists | | 4 | Verify frontmatter `title` | Equals `QA Test Entry` | | 5 | Verify frontmatter `date` | Equals `2026-06-18 10:00` | | 6 | Verify frontmatter `location_city` | Equals `Tokyo` | @@ -430,10 +436,10 @@ These scenarios cover the full round-trip: filling the form → saving → verif | 3 | Entry card present | Card with title `QA Test Entry` visible | | 4 | Date shown on card | `18 Jun 2026` | | 5 | Location badge on card | `📍 Tokyo, Japan` visible | -| 6 | Entry card link | `href` points to `/tracker/2026-06-18.entry` | +| 6 | Entry card link | `href` points to `/tracker/2026-06-18-1000-qa-test-entry.entry` | | 7 | Excerpt shown | Partial text of the body content visible | -**Automation:** curl /tracker; grep for "QA Test Entry", "18 Jun 2026", "Tokyo", "Japan", "/tracker/2026-06-18.entry" +**Automation:** curl /tracker; grep for "QA Test Entry", "18 Jun 2026", "Tokyo", "Japan", "/tracker/2026-06-18-1000-qa-test-entry.entry" --- @@ -441,7 +447,7 @@ These scenarios cover the full round-trip: filling the form → saving → verif | Step | Action | Expected Result | |---|---|---| -| 1 | GET http://100.96.115.96:8081/tracker/2026-06-18.entry | Page loads (200) | +| 1 | GET http://100.96.115.96:8081/tracker/2026-06-18-1000-qa-test-entry.entry | Page loads (200) | | 2 | Page title | `QA Test Entry` in `