Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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);
Comment | File | Size | Author |
---|---|---|---|
#19 | 2978283-19.patch | 11.08 KB | Lendude |
#19 | interdiff-2978283-17-19.txt | 2.7 KB | Lendude |
#17 | 2978283-17.patch | 9.5 KB | Lendude |
#17 | interdiff-2978283-12-17.txt | 501 bytes | Lendude |
#14 | 2978283-14-TEST_ONLY.patch | 4.5 KB | Lendude |
Comments
Comment #2
VladimirAusCan 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
followed by
Error for both standard and custom profiles.
Comment #3
VladimirAusPatch to get views going.
Comment #4
VladimirAusShould I apply it to 8.6 as well?
Comment #5
VladimirAusComment #7
interX CreditAttribution: interX as a volunteer and at Anvil commentedI 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.
Comment #8
interX CreditAttribution: interX as a volunteer and at Anvil commentedHere'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.
Comment #9
kim.pepperPosted without modification from https://twitter.com/chx/status/1067532945391521799 https://gist.github.com/chx/0832625f9ae14b113824729edf5bbe7a
Comment #10
LendudeNice 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.
Comment #12
LendudeFixed 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)
Comment #13
andypostLooks great but needs test-only patch
Comment #14
Lendude@andypost yeah sorry, forgot! Here we go.
Comment #16
andypostIMO ready
Comment #17
LendudeRemoved unused use and making sure the RTBC patch is the latest in the thread.
Comment #18
alexpottLet's not do assignment in an if for no real reason. Let's do
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.
Nice to have this tested.
Comment #19
Lendude#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!Comment #20
nwoodland CreditAttribution: nwoodland commentedPatch from #19 worked on my end. Thanks everyone!
Comment #21
AnaSwin CreditAttribution: AnaSwin commentedPatch worked for me (Drupal 8.6.10, PHP 7.2) Thx :)
Comment #22
VladimirAusWorks for Drupal 8.6.10 and PHP 7.2.13
Comment #25
alexpottBack to rtbc - unrelated test fail
Comment #26
alexpottCreating @LOBsTerr for creating the issue and myself code review
Comment #27
alexpottComment #28
alexpottCommitted and pushed 2b5a0b53db to 8.8.x and 5d64617b71 to 8.7.x. Thanks!
Fixed coding standards on commit.
Comment #32
fabiansierra5191 CreditAttribution: fabiansierra5191 as a volunteer and at Mobomo commentedThis is not fixed yet, I mean this ticket should not be closed. Patch from #19 worked. Tested in 8.7 version.
Comment #33
fabiansierra5191 CreditAttribution: fabiansierra5191 as a volunteer and at Mobomo commentedComment #34
fabiansierra5191 CreditAttribution: fabiansierra5191 as a volunteer and at Mobomo commentedUpdate: 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