Steps to reproduce
1. install standard 8.x
2. edit frontpage view

You see "Show: Missing style plugin | Missing style plugin". It should be "Show: Content | Teaser".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, vdc-empty-title.patch, failed testing.

The last submitted patch, vdc-empty-title.patch, failed testing.

dawehner’s picture

Priority: Normal » Major
Issue tags: +Needs tests

OOH

olli’s picture

Status: Needs work » Needs review
FileSize
12.57 KB

This removes all defaults from annotations and adds an isset() in fetchPluginNames().

olli’s picture

Those "Undefined index: title" notices are coming from calls to fetchPluginNames() from Drupal\views\Plugin\views\display\Feed::initDisplay() and the plugin ids are entity:user, entity:node and entity:comment. I don't see why/how the derivative definitions are not merged here. Any ideas?

dawehner’s picture

olli’s picture

FileSize
12.66 KB
1.29 KB

To reproduce the notices: install minimal profile, goto admin/modules, check aggregator, menu, views and click "Save configuration". Our derivatives do not work during menu_install() because viewsdata has a fresh module handler that is not loaded yet. Adding loadAll in menu_install or modulehandler::install fixes this but is there a reason why we are not loading it?

dawehner’s picture

Maybe we should reset it so it will be loaded again automatically later?

benjy’s picture

I had the same issue and can confirm that the attached patch fixes the problem.

dawehner’s picture

--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -611,6 +611,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
// @todo install_begin_request() creates a container without a kernel.
if ($kernel = \Drupal::service('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
$kernel->updateModules($module_filenames, $module_filenames);
+ \Drupal::moduleHandler()->loadAll();
}

at least $this->loadAll() could be used instead. Have you tried to use $this->reset() to lazy do that loading?

olli’s picture

FileSize
14.32 KB
3.04 KB

Re #10: It looks like it is not $this module handler but the other one from kernel->updateModules that we get in viewsdata.

Here's an alternative modifying #2184951: Allow plugins to declare themselves a derivative.

EDIT: This ignores entity:user, entity:comment and entity:node until they are found by our deriver. DerivativeDiscoveryDecorator::getDefinition would need a similar change.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Awesome work!

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work

I don't understand, why are we removing the defaults? That wasn't really explained.

And there aren't any tests yet, so not RTBC.

olli’s picture

+++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
@@ -81,24 +81,31 @@ public function getDefinitions() {
+        $plugin_definitions[$plugin_id] = $plugin_definition + $plugin_definitions[$plugin_id];

Re #13: With defaults, this will be something like array('title' => '', ...) + array('title' => 'Content', ...). Is there another way around this?

olli’s picture

Component: views.module » plugin system
FileSize
1.23 KB
2.76 KB

Would you prefer something like this to keep the defaults?

tim.plunkett’s picture

damiankloip’s picture

I also created #2221037: Empty base plugin definitions overwrite derivative definitions when a plugin (annotation/id) is used as a derivative, which was just closed as a dupe of this.

One thing that issue does that this does not, is keep any other default values that the derivative doesn't populate. I think that is a better approach, as you are guaranteed more consistency between plugin definitions then? I was also talking to chx about this, the method I used in above issue means you could not override an empty value on your plugin annotation as the derivative definition would win in that case.

Or do we say if you are doing this, derivatives have to specify all their keys manually (which I think this does?).

Or do we let the defaults array on plugin managers handle that instead? Then the annotation classes are purely for documentation purposes really.

damiankloip’s picture

Title: Missing style plugin in views ui » Missing row plugin in views ui

This is actually a missing row plugin but #2221503: Missing row plugin text in Views UI says 'style'. So closed issue from #16 was also correct in its naming. This is all the same thing :)

damiankloip’s picture

Status: Needs work » Needs review
FileSize
6.59 KB

Here is the patch from #2221037: Empty base plugin definitions overwrite derivative definitions when a plugin (annotation/id) is used as a derivative. I think it makes more sense to try and fix this at the derivate level, rather than the plugin level. Like mentioned before, this means it is hard to override a value with an empty one. But will that case come up really? In that case, you just don't make it a derivative or something.

thoughts? olli?

tim.plunkett’s picture

+++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
@@ -90,7 +90,10 @@ protected function getDerivatives(array $base_plugin_definitions) {
-            $derivative_definition = $base_plugin_definitions[$plugin_id] + ($derivative_definition ?: array());
+            $filtered_base = array_filter($base_plugin_definitions[$plugin_id]);
+            $derivative_definition = $filtered_base + ($derivative_definition ?: array());
+            // Add back any empty keys that the derivative didn't have.
+            $derivative_definition += $base_plugin_definitions[$plugin_id];

I really really prefer this approach. +1

olli’s picture

I think it makes more sense to try and fix this at the derivate level, rather than the plugin level.

I agree, just couldn't figure out how and removed empty defaults from the annotation class so they get filtered out in Plugin::__construct().

Like mentioned before, this means it is hard to override a value with an empty one.

Also with non-empty default (register_theme here) I thought it should get any value set by the derivative discovery so I removed that too.

#19 looks simple and works most of the time, and if it doesn't, use _alter() like before.

olli’s picture

Status: Needs review » Needs work

We still need to change and test DerivativeDiscoveryDecorator::getDefinition(), right?

damiankloip’s picture

FileSize
9.47 KB
4.79 KB

Yes! let's do that now. Added some unit test coverage too.

damiankloip’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Cool!

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 895d4ab on 8.x by catch:
    Issue #2188031 by olli, damiankloip: Missing row plugin in views ui.
    

Status: Fixed » Closed (fixed)

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