enhancement: add check() validation to PostTable and TemplateTable #229

Open
opened 2026-06-29 14:20:00 +00:00 by jmiller · 1 comment
Owner

Summary

PostTable and TemplateTable have no check() method, unlike ServiceTable which validates required fields, generates aliases, and sets timestamps. This allows invalid data to be stored.

Current State

  • ServiceTable (src/Table/ServiceTable.php): Has robust check() -- validates title, service_type, generates alias, sets created/modified timestamps, ensures valid JSON for credentials/params
  • PostTable (src/Table/PostTable.php): Empty -- no validation at all
  • TemplateTable (src/Table/TemplateTable.php): Empty -- no validation at all

Recommended Validation

PostTable::check()

  • article_id is required and > 0
  • service_id is required and > 0
  • status must be one of: queued, posting, posted, failed, scheduled, deleted, permanently_failed, cancelled
  • Set created/modified timestamps
  • Default retry_count to 0
  • Default platform_post_id, platform_response, error_message to empty string

TemplateTable::check()

  • service_type is required
  • title is required
  • template_body is required (non-empty)
  • Set created/modified timestamps

Impact

  • Severity: Low
  • Data integrity -- prevents storing records with missing required fields
  • Note: PostModel::prepareTable() already handles some of this for new posts via the admin form, but direct DB inserts (QueueProcessor, CrossPostDispatcher, DispatchController) bypass it
## Summary `PostTable` and `TemplateTable` have no `check()` method, unlike `ServiceTable` which validates required fields, generates aliases, and sets timestamps. This allows invalid data to be stored. ## Current State - **ServiceTable** (`src/Table/ServiceTable.php`): Has robust `check()` -- validates title, service_type, generates alias, sets created/modified timestamps, ensures valid JSON for credentials/params - **PostTable** (`src/Table/PostTable.php`): Empty -- no validation at all - **TemplateTable** (`src/Table/TemplateTable.php`): Empty -- no validation at all ## Recommended Validation ### PostTable::check() - `article_id` is required and > 0 - `service_id` is required and > 0 - `status` must be one of: queued, posting, posted, failed, scheduled, deleted, permanently_failed, cancelled - Set `created`/`modified` timestamps - Default `retry_count` to 0 - Default `platform_post_id`, `platform_response`, `error_message` to empty string ### TemplateTable::check() - `service_type` is required - `title` is required - `template_body` is required (non-empty) - Set `created`/`modified` timestamps ## Impact - **Severity:** Low - Data integrity -- prevents storing records with missing required fields - Note: `PostModel::prepareTable()` already handles some of this for new posts via the admin form, but direct DB inserts (QueueProcessor, CrossPostDispatcher, DispatchController) bypass it
Author
Owner

Branch created: feature/229-enhancement-add-check-validation-to-post

git fetch origin
git checkout feature/229-enhancement-add-check-validation-to-post
Branch created: [`feature/229-enhancement-add-check-validation-to-post`](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteCross/src/branch/feature/229-enhancement-add-check-validation-to-post) ```bash git fetch origin git checkout feature/229-enhancement-add-check-validation-to-post ```
Sign in to join this conversation.
No labels
Priority Medium
Type Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteCross#229