1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 03:34:33 +02:00

Add a minimumAge config setting for PagePathHistory module per processwire/processwire-issues#1014 and add an option for throwing a 404 while still allowing PagePathHistory to perform redirects (if it has any). Also add a function: wire404(); that you can call for this, in addition to: throw new Wire404Exception(true);

This commit is contained in:
Ryan Cramer
2019-11-12 12:06:08 -05:00
parent 4cc587bd1a
commit 595429d425
3 changed files with 79 additions and 11 deletions

View File

@@ -74,6 +74,14 @@ class Wire404Exception extends WireException {
*
*/
const codeFile = 4044;
/**
* 404 is a result of a front-end wire404() function call
*
* #pw-internal
*
*/
const codeFunction = 4045;
/**
* Anonymous 404 with no code provided

View File

@@ -1210,6 +1210,24 @@ function wireRegion($key, $value = null) {
return $result;
}
/**
* Stop execution with a 404 unless redirect URL available (for front-end use)
*
* This is an alternative to using a manual `throw new Wire404Exception()` and is recognized by
* PW as a front-end 404 where PagePathHistory (or potentially other modules) are still allowed
* to change the behavior of the request from a 404 to something else (like a 301 redirect).
*
* #pw-group-common
*
* @param string $message Optional message to send to Exception message argument (not used in output by default)
* @throws Wire404Exception
* @since 3.0.147
*
*/
function wire404($message = '') {
throw new Wire404Exception($message, Wire404Exception::codeFunction);
}
/**
* Create new WireArray, add given $items to it, and return it
*