Problem

impossible to add a view block using content entities with revision

Steps to reproduce

1) Add new view using entities with revisions for example : Content revisions, paragraph revisions
2) Check "Create a block"
3) Feel all required fields
4) Save the view

As a result you should see few warnings

Notice: Undefined variable: table in /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php on line 942
Notice: Undefined index: type in /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php on line 944

Which lead to the error

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

I have debugged it a little bit and found that in WizardPluginBase.php, we receive the wrong bundle value ".type" as result we can't get table data

$table_data = Views::viewsData()->get($table);
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LOBsTerr created an issue. See original summary.

VladimirAus’s picture

Can confirm this is an issue in Drupal 8.5.4.

When I'm trying to create view for content revisions (even if it's just master) I'm getting

Notice: Undefined index: in Drupal\views\Plugin\views\wizard\WizardPluginBase->defaultDisplayFiltersUser() (line 944 of /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php)
#0 /web/core/includes/bootstrap.inc(582): _drupal_error_handler_real(8, 'Undefined index...', '/web...', 944, Array)
#1 /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php(944): _drupal_error_handler(8, 'Undefined index...', '/web...', 944, Array)
#2 /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php(904): Drupal\views\Plugin\views\wizard\WizardPluginBase->defaultDisplayFiltersUser(Array, Object(Drupal\Core\Form\FormState))
#3 /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php(725): Drupal\views\Plugin\views\wizard\WizardPluginBase->defaultDisplayFilters(Array, Object(Drupal\Core\Form\FormState))
#4 /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php(699): Drupal\views\Plugin\views\wizard\WizardPluginBase->buildDisplayOptions(Array, Object(Drupal\Core\Form\FormState))
#5 /web/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php(1275): Drupal\views\Plugin\views\wizard\WizardPluginBase->instantiateView(Array, Object(Drupal\Core\Form\FormState))
#6 /web/core/modules/views_ui/src/ViewAddForm.php(167): Drupal\views\Plugin\views\wizard\WizardPluginBase->validateView(Array, Object(Drupal\Core\Form\FormState))
#7 [internal function]: Drupal\views_ui\ViewAddForm->validateForm(Array, Object(Drupal\Core\Form\FormState))
#8 /web/core/lib/Drupal/Core/Form/FormValidator.php(83): call_user_func_array(Array, Array)
#9 /web/core/lib/Drupal/Core/Form/FormValidator.php(276): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#10 /web/core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'view_add_form')
#11 /web/core/lib/Drupal/Core/Form/FormBuilder.php(575): Drupal\Core\Form\FormValidator->validateForm('view_add_form', Array, Object(Drupal\Core\Form\FormState))
#12 /web/core/lib/Drupal/Core/Form/FormBuilder.php(318): Drupal\Core\Form\FormBuilder->processForm('view_add_form', Array, Object(Drupal\Core\Form\FormState))
#13 /web/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('view_add_form', Object(Drupal\Core\Form\FormState))
#14 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#15 /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#16 /web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#18 /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#19 /vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 /vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#21 /web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#22 /web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#23 /web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#24 /web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#25 /web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#26 /web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#27 /vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#28 /web/core/lib/Drupal/Core/DrupalKernel.php(666): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1,  true)
#29 /web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#130 {main}.

followed by

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of /web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Error for both standard and custom profiles.

VladimirAus’s picture

Assigned: Unassigned » VladimirAus
Status: Active » Needs review

Should I apply it to 8.6 as well?

VladimirAus’s picture

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

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

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.

interX’s picture

I encountered the same issue. Basically, when you choose a type filter in the Wizard when creating a content Revisions view, it fails.
Since type is only stored on the node_field_data table and not in the revisions base_table (node_field_revision) this fails.

The lookup of the table based on the base_table or field names is insufficient in this case.

interX’s picture

Here's a patch that simply removes the filter for the Content Revision ViewsWizard plugin.
This doesn't fix the Paragraphs plugin, but the same can be done there.

Note, by removing the type filter in the wizard, it will have to be added manually in the view, and requires a relationship on the node data.

Of course, it would be better to allow a type filer for revisions in the wizard directly.

kim.pepper’s picture

Lendude’s picture

Nice fix in #9. Adding the test from #2975429: Error when creating a view of content revisions of a specific content type with some modifications.

Also leaving the test for $table in, because the fix in #9 works for node revisions, but not paragraphs.

The fix in #9 is not perfect, since the test fails.

Status: Needs review » Needs work

The last submitted patch, 10: 2978283-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Lendude’s picture

Status: Needs work » Needs review
FileSize
3.94 KB
9.54 KB

Fixed the failing test (you can't use created on node revisions) and added a test for the missing bundle data on a base table (the paragraphs use case)

andypost’s picture

Assigned: VladimirAus » Unassigned

Looks great but needs test-only patch

Lendude’s picture

@andypost yeah sorry, forgot! Here we go.

Status: Needs review » Needs work

The last submitted patch, 14: 2978283-14-TEST_ONLY.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

andypost’s picture

Status: Needs work » Reviewed & tested by the community

IMO ready

Lendude’s picture

Removed unused use and making sure the RTBC patch is the latest in the thread.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
    @@ -95,4 +96,48 @@ protected function defaultDisplayOptions() {
    +    if (($type = $form_state->getValue(['show', 'type'])) && $type != 'all') {
    

    Let's not do assignment in an if for no real reason. Let's do

        $type = $form_state->getValue(['show', 'type']);
        if ($type && $type !== 'all') {
    

    I realise this is c&p from \Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayFiltersUser

    The other thing here is do we have test coverage of selecting the all option in this case? Setting to needs work to either add coverage or point out the existing coverage.

  2. +++ b/core/modules/views/tests/src/Functional/Wizard/EntityTestRevisionTest.php
    @@ -0,0 +1,43 @@
    +  /**
    +   * Tests creating a view of revisions where the type is not on the base table.
    +   */
    +  public function testRevisionsViewWithNoTypeOnBaseTable() {
    

    Nice to have this tested.

Lendude’s picture

Status: Needs work » Needs review
FileSize
2.7 KB
11.08 KB

#18.1 changed the if. The refactoring of the test actually removed that case (naughty me), so I've added it back in, thanks for spotting that!

nwoodland’s picture

Patch from #19 worked on my end. Thanks everyone!

AnaSwin’s picture

Patch worked for me (Drupal 8.6.10, PHP 7.2) Thx :)

VladimirAus’s picture

Status: Needs review » Reviewed & tested by the community

Works for Drupal 8.6.10 and PHP 7.2.13

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 19: 2978283-19.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

Back to rtbc - unrelated test fail

alexpott’s picture

Creating @LOBsTerr for creating the issue and myself code review

alexpott’s picture

Title: When we create a view with revisions Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTra » Creating a view with revisions triggers Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist.
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 2b5a0b53db to 8.8.x and 5d64617b71 to 8.7.x. Thanks!

diff --git a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
index 394eb9ba01..14119d4fb5 100644
--- a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
+++ b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
@@ -112,7 +112,7 @@ protected function defaultDisplayFiltersUser(array $form, FormStateInterface $fo
         'value' => [$type => $type],
         'entity_type' => 'node',
         'entity_field' => 'type',
-        'plugin_id' =>  'bundle',
+        'plugin_id' => 'bundle',
       ];
     }
     return $filters;
@@ -140,5 +140,4 @@ protected function buildDisplayOptions($form, FormStateInterface $form_state) {
     return $display_options;
   }
 
-
 }

Fixed coding standards on commit.

  • alexpott committed 2b5a0b5 on 8.8.x
    Issue #2978283 by Lendude, VladimirAus, interX, kim.pepper, alexpott,...

  • alexpott committed 5d64617 on 8.7.x
    Issue #2978283 by Lendude, VladimirAus, interX, kim.pepper, alexpott,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

fabiansierra5191’s picture

This is not fixed yet, I mean this ticket should not be closed. Patch from #19 worked. Tested in 8.7 version.

fabiansierra5191’s picture

fabiansierra5191’s picture

Update: my fault, the version that has this error is 8.6.x and patch from #19 works for it but this is already fixed in 8.7.x and above