diff --git a/core/modules/statistics/statistics.php b/core/modules/statistics/statistics.php index 52f7e08b88..d8c8f82d14 100644 --- a/core/modules/statistics/statistics.php +++ b/core/modules/statistics/statistics.php @@ -9,6 +9,7 @@ use Symfony\Component\HttpFoundation\Request; try { + // Added try/catch block to handle PDOException. chdir('../../..'); $autoloader = require_once 'autoload.php'; @@ -23,7 +24,9 @@ ->get('count_content_views'); if ($views) { - $nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT); + // Range set so that value of nid does not goes out of bound + // and PDOException is not triggered. + $nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 4294967295]]); if ($nid) { $container->get('request_stack')->push(Request::createFromGlobals()); $container->get('statistics.storage.node')->recordView($nid); @@ -31,5 +34,5 @@ } } catch (\Exception $e) { - // Never pres + // Do nothing. }