When I expose my entity, which has no revisions, to Views the following appears in the log
Notice: Undefined index: entity revision in Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (line 277 of /home/matslats/localhost/drupal8/core/modules/views/src/Plugin/views/query/QueryPluginBase.php).
which relates to this code:

      $entity_tables[$base_table_data['table']['entity type']] = array(
        'base' => $base_table,
        'alias' => $base_table,
        'relationship_id' => 'none',
        'entity_type' => $base_table_data['table']['entity type'],
        'revision' => $base_table_data['table']['entity revision'],
      );

which assumes that every base table exposed to views has an entity revision

Comments

webkarthik’s picture

Assigned: Unassigned » webkarthik
Status: Active » Needs review
StatusFileSize
new1.06 KB

Include revision only if it is available

Status: Needs review » Needs work

The last submitted patch, 1: views-entity-add-revision-if-exist-2477847-1.patch, failed testing.

alx_benjamin’s picture

Here is another patch.
It checks for existance of 'entity revision' key.

-------------------------------------------------
Sponsored by http://reallifedesign.co.uk/

alx_benjamin’s picture

Status: Needs work » Needs review
StatusFileSize
new1.34 KB

Resubmitting previous patch. Had a little typo in it.
-------------------------------------------------
Sponsored by http://reallifedesign.co.uk/

Status: Needs review » Needs work

The last submitted patch, 4: views-entity-add-revision-if-exist-2477847-3.patch, failed testing.

webkarthik’s picture

Assigned: webkarthik » Unassigned
alx_benjamin’s picture

Let's see if this one is gonna pass tests
-------------------------------------------------
Sponsored by http://reallifedesign.co.uk/

alx_benjamin’s picture

Status: Needs work » Needs review
dawehner’s picture

Issue tags: +Needs tests

.

hussainweb’s picture

I am wondering how you got the error. Can you share relevant parts of views data class? The classes in core use \Drupal\views\EntityViewsData::getViewsData() which sets that field to FALSE if the entity is not revisionable. Can you consider using that? See \Drupal\entity_test\EntityTestViewsData::getViewsData for an example.

If you can't use that method, consider setting the key to FALSE in your method. I am not sure if it's a contract but it makes sense to provide defaults anyway.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Status: Needs review » Postponed (maintainer needs more info)
platinum1’s picture

@dawehner I have essentially the same error on 8.2.DEV and PHP 7.0.3

Notice: Undefined index: base in Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (line 286 of /home/solution/public_html/mydomain.com/core/modules/views/src/Plugin/views/query/QueryPluginBase.php).

I get the error any time someone calls up the primary view on the site.

Notice: Undefined index: base in Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (line 286 of core/modules/views/src/Plugin/views/query/QueryPluginBase.php).

Drupal\views\Plugin\views\query\QueryPluginBase->getEntityTableInfo() (Line: 1247)
Drupal\views\Plugin\views\query\Sql->query() (Line: 1356)
Drupal\views\Plugin\views\query\Sql->build(Object) (Line: 1308)
Drupal\views\ViewExecutable->build() (Line: 349)
Drupal\views\Plugin\views\display\PathPluginBase->execute() (Line: 167)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1617)
Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 78)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array) (Line: 381)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 206)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 120)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 74)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

What other information do you need @dawehner?

platinum1’s picture

Status: Postponed (maintainer needs more info) » Active
platinum1’s picture

That should have been PHP 7.0.6

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joachim’s picture

This is the wrong fix. 'entity revision' is a required property, which should be TRUE or FALSE to say whether an entity table is for revisions or not.

It's possible the OP was encountering this bug: #3004300: EntityViewsData fails to set 'entity revision' in the table data for an entity's revision table.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

This is a bug smash issue of the day. I read the issue and skimmed the related issue mentioned in #21. I do think that this is a duplicate of that issue. And although this is earlier, the patch over there has been looked at by a views maintainers.

Therefor closing this as a duplicate, moving credit.