Merge pull request #37073 from nextcloud/backport/37026/stable26

[stable26] fix: Avoid log spam on 404 routes not using GET
This commit is contained in:
Julius Härtl 2023-03-09 12:44:40 +01:00 committed by GitHub
commit ffb1a39bba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -80,6 +80,7 @@ use OCP\Server;
use OCP\Share;
use OCP\User\Events\UserChangedEvent;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use function OCP\Log\logger;
require_once 'public/Constants.php';
@ -1097,7 +1098,9 @@ class OC {
try {
Server::get(\OC\Route\Router::class)->match('/error/404');
} catch (\Exception $e) {
logger('core')->emergency($e->getMessage(), ['exception' => $e]);
if (!$e instanceof MethodNotAllowedException) {
logger('core')->emergency($e->getMessage(), ['exception' => $e]);
}
$l = Server::get(\OCP\L10N\IFactory::class)->get('lib');
OC_Template::printErrorPage(
$l->t('404'),