Problem/Motivation
The following error has been showing in error logs:
php-error ded-15106 [20-Jan-2021 22:56:13 UTC] TypeError: Argument 3 passed to Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::__construct() must be an instance of Exception or null, array given, called in REDACTED/fast_404/src/Fast404.php on line 214 in REDACTED/vendor/symfony/http-kernel/Exception/ServiceUnavailableHttpException.php on line 25 #0 REDACTED/fast_404/src/Fast404.php(214): Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException->__construct(3, 'The requested U...', Array)
Proposed resolution
Use the $this->t function for the exception message:
throw new ServiceUnavailableHttpException(3, $this->t('The requested URL "@path" was not found on this server. Try again shortly.', ['@path' => $this->request->getPathInfo()]));
Comment | File | Size | Author |
---|---|---|---|
#10 | fast_404_3x-3194034-10.patch | 1.33 KB | carsoncho |
| |||
#6 | fast_404_3194034-6.patch | 1.15 KB | PCate |
|
Issue fork fast_404-3194034
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
PCate CreditAttribution: PCate commentedComment #4
gg4 CreditAttribution: gg4 commentedIIRC, not translating the exception is intentional. #2055851: Remove translation of exception messages
Comment #5
PCate CreditAttribution: PCate commented@bonus in that case should we just do a string concatenation with UrlHelper::stripDangerousProtocols() for the path variable?
Something like:
throw new ServiceUnavailableHttpException(3, 'The requested URL "' . UrlHelper::stripDangerousProtocols($this->request->getPathInfo()) . '" was not found on this server. Try again shortly.');
?Comment #6
PCate CreditAttribution: PCate commentedChanges as patch attached.
Comment #7
Kristen PolThanks for the issue, patches, and review!
@PCate Could you please add any specific steps to reproduce this?
Comment #8
Kristen PolAlso, the issue summary needs updating as the approach changed.
Comment #9
azinck CreditAttribution: azinck at Forum One commentedI agree this is needed. +1 for the approach in #6.
To reproduce this error you need to have code that calls \Drupal\fast404\Fast404::response() without passing TRUE as an argument. This appears to only happen in fast404_preboot(), so to see this you probably have to be using the advanced installation which entails modifying your settings.php to call fast404_preboot(). If you've done that, then you will hit this error every time fast404 returns a 404.
Comment #10
carsoncho CreditAttribution: carsoncho at Forum One commentedUploading patch that resolves this for the 3.x branch.