#2237 closed Enhancement (fixed)
Add 'reason' parameter to forward() to allow proper headers and more flexible destinations via plugin hooks
| Reported by: | cash | Owned by: | ewinslow |
|---|---|---|---|
| Priority: | normal | Milestone: | Elgg 1.8.0 |
| Component: | Core | Version: | 1.7 |
| Severity: | minor | Keywords: | |
| Cc: | brettp, evan.b.winslow@… | Difficulty: | moderate |
Description
Right now if a page does not exist (pg/doesnotexist/), the user is forwarded to the front page. Perhaps add a plugin hook to the page handler so that sites can decide to send to an error page
Attachments (1)
Change History (12)
comment:1 Changed 3 years ago by ewinslow
- Cc evan.b.winslow@… added
comment:2 Changed 3 years ago by cash
Makes sense to me.
gatekeeper could call forward and passes in "login" as the reason/destination. The page handler passes in "404" when the page handling system cannot find a page.
comment:3 Changed 3 years ago by ewinslow
What else needs "reason"s?
- admin_gatekeeper: 'admin'
- group_gatekeeper: 'member'
anything else?
I think "reason" would be better than "destination" because in the case of admin_gatekeeper(), you'd want to boot them if they're logged in and not an admin, but want to let them log in if they weren't logged in, in case they are an admin. So the destination is unclear.
comment:4 Changed 3 years ago by brettp
- Difficulty set to moderate
comment:5 Changed 3 years ago by brettp
- Summary changed from Allow sites to register a 404 page to Add 'reason' parameter to forward() to allow proper headers and more flexible destinations via plugin hooks
comment:6 Changed 3 years ago by ewinslow
- Owner set to ewinslow
- Status changed from new to assigned
comment:7 Changed 3 years ago by ewinslow
- Resolution set to fixed
- Status changed from assigned to closed
(In [svn:7373]) Fixes #2237: Added 'reason' parameter to forward() to allow proper headers and more flexible destinations via plugin hooks. Also made use of this in core gatekeeper functions and in pagehandler.php
comment:8 Changed 3 years ago by brettp
I'd like to use as many existing HTTP status codes as we can. Would we want to put some handling in core's forward() to emit headers if the reason is an HTTP status code? Another possibility is allowing an array of reason and code, which would provide flexibility for plugins to say why it's being forwarded and also allow remove boilerplate header() calls in action files or the hooks.
comment:9 Changed 3 years ago by ewinslow
We could add a third parameter to forward() that specifies http status code. I imagine this would default to 301/200?
comment:10 Changed 3 years ago by ewinslow
er... not 301. What would make sense for actions forwarding when they complete?
comment:11 Changed 3 years ago by cash
302 or 303 - PHP defaults to 302

Perhaps we could use your 'forward', 'system' hook and add a "reason" parameter.
This parameter could also be used to improve gatekeeper forward because it would allow plugins to forward to a dedicated login page (rather than the home page), for example, when 'gatekeeper' blocks someone.