PhoenixKit.Modules.Publishing.Web.Controller.Fallback
(PhoenixKitPublishing v0.1.6)
Copy Markdown
View Source
404 fallback handling for the publishing controller.
Policy
Smart fallback only fires when the requested group exists. The signal is "you're inside a real publishing URL but I can't find this specific post / language / time" — in that case we redirect to the nearest valid parent (other-language version, other-time-on-date, group listing) with a flash explaining the substitution.
When the group itself doesn't exist, the request gets a clean 404.
This is critical when url_prefix is "/": publishing's catch-all
routes then sit at the host's absolute root, so any path the host app
doesn't claim earlier flows into this controller. Falling back to "the
first group in the DB" (the previous behaviour) would hijack random
host-app URLs and redirect them to an unrelated page.
Fallback chain (group-existing case only)
:not_found(post trashed/deleted) → group listing:post_not_found | :unpublished | :version_access_disabledon a slug path → other languages → group listing- same on a timestamp path → other languages → other times on the date → group listing
- any other reason with a known group → group listing
Summary
Functions
Fallback for timestamp mode posts - comprehensive fallback chain
Tries to find any available published language version of the post.
Tries each language for timestamp mode until finding a published version.
Handles 404 not found responses with smart fallback.
Functions
Fallback for timestamp mode posts - comprehensive fallback chain:
- Try other languages for the exact date/time
- If time doesn't exist, try other times on the same date
- If date has no posts, fall back to group listing
Tries to find any available published language version of the post.
Priority:
- Check for published versions in the SAME language first (across all versions)
- Then try other languages
- Falls back to group listing if no published versions exist
Note: fetch_post now handles finding the latest published version automatically, so we can just use base URLs here (no version-specific URLs needed)
Tries each language for timestamp mode until finding a published version.
Handles 404 not found responses with smart fallback.