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
Comment #1
webkarthik commentedInclude revision only if it is available
Comment #3
alx_benjamin commentedHere is another patch.
It checks for existance of 'entity revision' key.
-------------------------------------------------
Sponsored by http://reallifedesign.co.uk/
Comment #4
alx_benjamin commentedResubmitting previous patch. Had a little typo in it.
-------------------------------------------------
Sponsored by http://reallifedesign.co.uk/
Comment #6
webkarthik commentedComment #7
alx_benjamin commentedLet's see if this one is gonna pass tests
-------------------------------------------------
Sponsored by http://reallifedesign.co.uk/
Comment #8
alx_benjamin commentedComment #9
dawehner.
Comment #10
hussainwebI 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::getViewsDatafor 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.
Comment #12
dawehnerComment #13
platinum1 commented@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?
Comment #14
platinum1 commentedComment #15
platinum1 commentedThat should have been PHP 7.0.6
Comment #21
joachim commentedThis 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.
Comment #27
quietone commentedThis 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.