Skip to content

fix(public-tickets): honor guest_policy_mode in TicketService::create_guest#36

Open
mpge wants to merge 1 commit intomainfrom
fix/widget-honors-guest-policy
Open

fix(public-tickets): honor guest_policy_mode in TicketService::create_guest#36
mpge wants to merge 1 commit intomainfrom
fix/widget-honors-guest-policy

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented Apr 24, 2026

Summary

Last framework in the cross-framework fix sweep for the widget↔settings-disconnection bug. Completes the set alongside escalated-laravel#72, escalated-rails#47, escalated-django#44, escalated-adonis#52, and escalated-nestjs#27.

The admin settings page at `Admin → Settings → Public Tickets` (shipped in #34) persists `guest_policy_mode` / `guest_policy_user_id` / `guest_policy_signup_url_template` to the `EscalatedSetting` table, but `TicketService::create_guest` wrote `requester_id = null` unconditionally, ignoring the mode. Result: the admin settings page had zero behavioral effect on public ticket creation.

What changed

Fixed inside `TicketService::create_guest` rather than in each call site — that method is the shared service both public entry points go through:

  • `Api\Widget_Controller::create_ticket` (the REST widget endpoint).
  • `Frontend\Ajax_Handler` (the `[escalated_portal]` shortcode's guest form).

One fix → both paths wired.

Mode Behavior
`unassigned` (default) Existing behavior — `requester_id` null, `guest_*` fields set.
`guest_user` Route to the configured shared WordPress user id via `requester_id`. Still records `guest_name` / `guest_email` so agents see who submitted.
`prompt_signup` Same ticket-create path as unassigned today; signup-invite emission is a listener-level follow-up.

Misconfigured `guest_user` mode (zero / missing user id) falls through to unassigned so bad admin input can't 500 public submissions.

Test plan

  • `php -l` clean on both modified files.
  • 4 new PHPUnit cases in `Test_Ticket_Service`: default-unassigned path regression, `guest_user` routes to a real WordPress user (via `self::factory()->user->create`), misconfigured `guest_user` fallback, `prompt_signup` path.
  • The PHPUnit suite needs the WP test harness (not available locally); CI runs it on merge.

Running scoreboard

NestJS #27 · Laravel #72 · Rails #47 · Django #44 · Adonis #52 · WordPress (this PR)6 of 6 frameworks done.

…_guest

Completes the cross-framework sweep for the widget/settings
disconnection bug (escalated-laravel#72, escalated-rails#47,
escalated-django#44, escalated-adonis#52, escalated-nestjs#27 —
this is the last framework).

The admin settings page at Admin → Settings → Public Tickets (shipped
in #34) persists guest_policy_mode / guest_policy_user_id /
guest_policy_signup_url_template to the EscalatedSetting table, but
TicketService::create_guest wrote requester_id=null unconditionally,
ignoring the mode. Result: the admin settings page had zero behavioral
effect on public ticket creation.

Fixing inside create_guest covers both callers at once — the REST API
widget controller (Api\Widget_Controller::create_ticket) and the
frontend AJAX handler (Frontend\Ajax_Handler, used by the
[escalated_portal] shortcode's guest form).

Modes:
  - unassigned (default): requester_id null, guest_* fields set.
  - guest_user: requester_id = configured shared WordPress user id.
    Still records guest_name / guest_email so agents see who submitted.
  - prompt_signup: same ticket-create path as unassigned today;
    signup-invite emission is a listener-level follow-up.

Misconfigured guest_user (zero / missing user id) falls through to
unassigned so bad admin input can't 500 public submissions.

4 new PHPUnit cases in Test_Ticket_Service cover: default-unassigned
path (regression), guest_user routing to a real WordPress user,
misconfigured guest_user fallback, prompt_signup path.

PHP-lint clean locally; the PHPUnit suite needs the WP test harness
so CI will exercise the new tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant