diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php
index c307178..0bb8234 100644
--- a/core/modules/views/src/Plugin/views/HandlerBase.php
+++ b/core/modules/views/src/Plugin/views/HandlerBase.php
@@ -700,10 +700,8 @@ public static function getTableJoin($table, $base_table) {
    * {@inheritdoc}
    */
   public function getEntityType() {
-    // If the user has configured a relationship on the handler take that into
-    // account.
-    if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
-      $views_data = $this->getViewsData()->get($this->view->relationship->table);
+    if ($this->table !== NULL) {
+      $views_data = $this->getViewsData()->get($this->table);
     }
     else {
       $views_data = $this->getViewsData()->get($this->view->storage->get('base_table'));
diff --git a/core/modules/views/src/Tests/Handler/HandlerTest.php b/core/modules/views/src/Tests/Handler/HandlerTest.php
index b182dee..b5b9cd9 100644
--- a/core/modules/views/src/Tests/Handler/HandlerTest.php
+++ b/core/modules/views/src/Tests/Handler/HandlerTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\views\Tests\Handler;
 
+use Drupal\views\Entity\View;
 use Drupal\views\ViewExecutable;
 use Drupal\views\Tests\ViewTestBase;
 use Drupal\views\Plugin\views\HandlerBase;
@@ -265,7 +266,20 @@ public function testRelationshipUI() {
     // Remove the relationship and make sure no relationship option appears.
     $this->drupalPostForm('admin/structure/views/nojs/handler/test_handler_relationships/default/relationship/nid', array(), t('Remove'));
     $this->drupalGet($handler_options_path);
-    $this->assertNoFieldByName($relationship_name, 'Make sure that no relationship option is available');
+    $this->assertNoFieldByName($relationship_name, NULL, 'Make sure that no relationship option is available');
+
+    // Create a view of comments with node relationship.
+    View::create(['base_table' => 'comment', 'id' => 'test_get_entity_type'])->save();
+    $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_get_entity_type/default/relationship', ['name[comment_field_data.node]' => 'comment_field_data.node'], t('Add and configure relationships'));
+    $this->drupalPostForm(NULL, [], t('Apply'));
+    // Add a content type filter.
+    $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_get_entity_type/default/filter', ['name[node_field_data.type]' => 'node_field_data.type'], t('Add and configure filter criteria'));
+    $this->assertOptionSelected('edit-options-relationship', 'node');
+    $this->drupalPostForm(NULL, ['options[value][page]' => 'page'], t('Apply'));
+    // Check content type filter options.
+    $this->drupalGet('admin/structure/views/nojs/handler/test_get_entity_type/default/filter/type');
+    $this->assertOptionSelected('edit-options-relationship', 'node');
+    $this->assertFieldChecked('edit-options-value-page');
   }
 
   /**
