diff --git a/core/modules/statistics/src/Tests/StatisticsLoggingTest.php b/core/modules/statistics/src/Tests/StatisticsLoggingTest.php
index 152c95ae60..f598a6fee4 100644
--- a/core/modules/statistics/src/Tests/StatisticsLoggingTest.php
+++ b/core/modules/statistics/src/Tests/StatisticsLoggingTest.php
@@ -3,6 +3,7 @@
 namespace Drupal\statistics\Tests;
 
 use Drupal\simpletest\WebTestBase;
+use Drupal\node\Entity\Node;
 
 /**
  * Tests request logging for cached and uncached pages.
@@ -125,6 +126,17 @@ public function testLogging() {
     $this->client->post($base_root . $stats_path, ['form_params' => $post]);
     $node_counter = statistics_get($this->node->id());
     $this->assertIdentical($node_counter['totalcount'], '1');
+
+    // Try fetching statistics for an invalid node ID and verify it returns
+    // an empty array.
+    $node_id = 10000000000000000;
+    $node = Node::load($node_id);
+    $this->assertNull($node);
+
+    // This is a test specifically for the deprecated statistics_get() function
+    // and so should remain unconverted until that function is removed.
+    $result = statistics_get($node_id);
+    $this->assertIdentical($result, FALSE);
   }
 
 }
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index a7f1e10601..4d7f42a33c 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -10,6 +10,7 @@
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\Core\Url;
 use Drupal\node\NodeInterface;
+use Drupal\statistics\StatisticsViewsResult;
 
 /**
  * Implements hook_help().
@@ -125,6 +126,12 @@ function statistics_get($id) {
   if ($id > 0) {
     /** @var \Drupal\statistics\StatisticsViewsResult $statistics */
     $statistics = \Drupal::service('statistics.storage.node')->fetchView($id);
+
+    // For backwards compatibility, return FALSE if an invalid node ID was
+    // passed in.
+    if (!($statistics instanceof StatisticsViewsResult)) {
+      return FALSE;
+    }
     return [
       'totalcount' => $statistics->getTotalCount(),
       'daycount' => $statistics->getDayCount(),
