diff --git a/module/VuFindSearch/src/VuFindSearch/Service.php b/module/VuFindSearch/src/VuFindSearch/Service.php
index 2085c8e6b3d8c4dfc8e32de1833d8d60fe7bd7e0..905ec0b89a62d80cca3252032ac3e69e1c993286 100644
--- a/module/VuFindSearch/src/VuFindSearch/Service.php
+++ b/module/VuFindSearch/src/VuFindSearch/Service.php
@@ -205,7 +205,6 @@ class Service
     public function random($backend, $query, $limit = 20, $params = null)
     {
         $params  = $params ?: new ParamBag();
-        $backendString = $backend;
         $context = __FUNCTION__;
         $args = compact('backend', 'query', 'limit', 'params', 'context');
         $backend = $this->resolve($backend, $args);
@@ -249,7 +248,6 @@ class Service
                 // Default case: retrieve n random records:
                 $response = false;
                 $retrievedIndexes = array();
-                $retrievedRecordIds = array();
                 for ($i = 0; $i < $limit; $i++) {
                     $nextIndex = rand(0, $total_records - 1);
                     while (in_array($nextIndex, $retrievedIndexes)) {