From ef5c24972ce8b54a5b74ef2487827a00cbfee040 Mon Sep 17 00:00:00 2001 From: pixelrausch Date: Thu, 14 Dec 2017 14:24:12 +0100 Subject: [PATCH 1/3] Enable 404 Error Handling for Userfunc Because of some old content in the Google Index i tried to get a 404 Error for no longer existing subpages configured via userfunc in the fixedPostVars. So I update the UrlDecoder Class and added the following to the realurl configuration: GETvar' => 'myVar', 'enable404forInvalidAlias' => 1, 'userFunc' => .... If there was already an existing way to do this, I'm sorry I wasn't able to find it. :) --- Classes/Decoder/UrlDecoder.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Classes/Decoder/UrlDecoder.php b/Classes/Decoder/UrlDecoder.php index 1a37733e..3521adb1 100644 --- a/Classes/Decoder/UrlDecoder.php +++ b/Classes/Decoder/UrlDecoder.php @@ -834,6 +834,10 @@ protected function decodeUrlParameterBlockUsingUserFunc(array $configuration, $g if (is_numeric($value) || is_string($value)) { $requestVariables[$configuration['GETvar']] = $value; $result = TRUE; + } else { + if ($configuration['enable404forInvalidAlias']) { + $this->throw404('Could not find element with id or name like "' . $value . '".'); + } } } From efedc865d25c4f1c2fc95e2bf0f0b6b7de54a0dd Mon Sep 17 00:00:00 2001 From: pixelrausch Date: Fri, 15 Dec 2017 11:05:55 +0100 Subject: [PATCH 2/3] Userfunc Encoding Return Value If you try to encode, for example a hidden translation of something in your own extension, it is useful to reset it to the previous value. Before I changed this file, the requested uid was returned. --- Classes/Encoder/UrlEncoder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Classes/Encoder/UrlEncoder.php b/Classes/Encoder/UrlEncoder.php index a6270d99..78e14515 100644 --- a/Classes/Encoder/UrlEncoder.php +++ b/Classes/Encoder/UrlEncoder.php @@ -917,6 +917,8 @@ protected function encodeUrlParameterBlockUsingUserFunc(/** @noinspection PhpUnu if (is_numeric($getVarValue) || is_string($getVarValue)) { $segments[] = rawurlencode($getVarValue); $result = TRUE; + } else { + $result = $previousValue; } } From 41b0ebb80b582ab9e9aadd0e9868c94589872ab6 Mon Sep 17 00:00:00 2001 From: pixelrausch Date: Fri, 15 Dec 2017 13:40:21 +0100 Subject: [PATCH 3/3] Update UrlEncoder.php That was wrong I'm sorry - with my change i got wrong entries for the previous value. --- Classes/Encoder/UrlEncoder.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Classes/Encoder/UrlEncoder.php b/Classes/Encoder/UrlEncoder.php index 78e14515..a6270d99 100644 --- a/Classes/Encoder/UrlEncoder.php +++ b/Classes/Encoder/UrlEncoder.php @@ -917,8 +917,6 @@ protected function encodeUrlParameterBlockUsingUserFunc(/** @noinspection PhpUnu if (is_numeric($getVarValue) || is_string($getVarValue)) { $segments[] = rawurlencode($getVarValue); $result = TRUE; - } else { - $result = $previousValue; } }