fix(public-tickets): honor guest_policy_mode in TicketService::create_guest#36
Open
fix(public-tickets): honor guest_policy_mode in TicketService::create_guest#36
Conversation
…_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.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
One fix → both paths wired.
Misconfigured `guest_user` mode (zero / missing user id) falls through to unassigned so bad admin input can't 500 public submissions.
Test plan
Running scoreboard
NestJS #27 · Laravel #72 · Rails #47 · Django #44 · Adonis #52 · WordPress (this PR) — 6 of 6 frameworks done.