Skip to content

Commit

Permalink
Merge pull request #37026 from nextcloud/fix/route-logs
Browse files Browse the repository at this point in the history
fix: Avoid log spam on 404 routes not using GET
  • Loading branch information
nickvergessen authored Mar 7, 2023
2 parents e1b91fe + bbc6eee commit 1e026a9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
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';
Expand Down Expand Up @@ -1097,7 +1098,9 @@ public static function handleRequest(): void {
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'),
Expand Down

0 comments on commit 1e026a9

Please sign in to comment.