diff --git a/src/Plugin/views/filter/TaxonomyEntityIndexTidDepth.php b/src/Plugin/views/filter/TaxonomyEntityIndexTidDepth.php
index dd30bab8df0974655980c943e50d45ea3165d0e7..74447f8b587067dcc8c909702d40f7bef493fe57 100644
--- a/src/Plugin/views/filter/TaxonomyEntityIndexTidDepth.php
+++ b/src/Plugin/views/filter/TaxonomyEntityIndexTidDepth.php
@@ -121,14 +121,14 @@ class TaxonomyEntityIndexTidDepth extends TaxonomyIndexTidDepth implements Conta
     if ($this->options['depth'] > 0) {
       $subquery->leftJoin('taxonomy_term__parent', 'th', "th.entity_id = tei.tid");
       $last = "th";
-      foreach (range(1, abs($this->options['depth'])) as $count) {
+      foreach (range(1, abs((int)$this->options['depth'])) as $count) {
         $subquery->leftJoin('taxonomy_term__parent', "th$count", "$last.parent_target_id = th$count.entity_id");
         $where->condition("th$count.entity_id", $this->value, $operator);
         $last = "th$count";
       }
     }
     elseif ($this->options['depth'] < 0) {
-      foreach (range(1, abs($this->options['depth'])) as $count) {
+      foreach (range(1, abs((int)$this->options['depth'])) as $count) {
         $subquery->leftJoin('taxonomy_term__parent', "th$count", "$last.entity_id = th$count.parent_target_id");
         $where->condition("th$count.entity_id", $this->value, $operator);
         $last = "th$count";