from #1879774: Catch plugin exceptions for invalid views display plugins, reported by oadaeh:

I did a brand new install with D8 code downloaded less than an hour ago (which means the committed changes from this issue are in it) into a new database, and then performed the following steps:

Created a view (of users) with a block display
Placed that block in a region
Deleted the view
Displayed or refreshed a page that has the block on it
I get a WSOD. (When I did this last night, I was also getting an error message, but I'm not getting it now, so I can't post it).

I get this from Apache:
PHP Fatal error: Call to a member function access() on a non-object in /.../core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php on line 56

If I delete the associated .yml file, everything is fine again.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because we are just asking for tests.
Issue priority Major because its a core feature coverage issue

Comments

catch’s picture

Priority: Major » Critical
dawehner’s picture

Status: Active » Needs review
StatusFileSize
new13.08 KB

This is indeed annoying and there are multiple problems here, but this at least fixes the UI and

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, vdc-2018493-2.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#2: vdc-2018493-2.patch queued for re-testing.

I don't believe all those failures.

Status: Needs review » Needs work
Issue tags: +VDC

The last submitted patch, vdc-2018493-2.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new3.43 KB
new14.78 KB

This is a nice start, basically the same approach I was thinking of. Another big problem is also when a view is disabled. Because the derivative fetcher only gets enabled views, I think we might have to have something in Block::getPlugin() to deal with this, as is a view is disabled we defintely want to keep the actual block. If we do something like this in getPlugin() the good is that it will not show the block and will be removed from the block admin page, and will return when a view is enabled again. Either that or we let all views regardless of status in the derivatives, and then worry about signifying the view is disabled in the UI somehow? not sure.

Added a test for the disabled view case, and the changes to getPlugin(), with a todo with how to handle the caught exception - This is a similar issue to the broken displays plugin handling.

damiankloip’s picture

StatusFileSize
new1.49 KB
new15.26 KB

I spoke to Tim, we should definitely be encapsulating any of the exception logic in the plugin bag, it's things like this that we are using plugin bags for I guess. But how do we deal with the exception logic in BlockPluginBag and it's module stuff? Just remove it?

Status: Needs review » Needs work

The last submitted patch, 2018493-7.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new3.86 KB
new17.99 KB

This is green now.

olli’s picture

Status: Needs review » Needs work
+++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php
@@ -49,7 +49,7 @@ protected function setUp() {
-  protected function testDeleteBlockDisplay() {
+  protected function ptestDeleteBlockDisplay() {

Oops

jghyde’s picture

I just tested the user story in the topic opener from damiankloip with the latest git pull of 8.x. after creating view of users, adding the Views:users block to sidebar right, deleting view and viewing page as noted, no WSOD and the log files are clear.

MAMP, php 5.4

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.13 KB
new16.73 KB

There we go.

R.Hendel’s picture

Status: Needs review » Reviewed & tested by the community

I applied patch #12 against a freshly installed current 8.x
- I created a view with displays newest five items in a block
- I created a view with displays newest users in a block
- I placed both blocks in header region and reloaded homepage. Both blocks were there.
- I deleted view with newest five items and reloaded homepage. No errors and only users-block was there.
- I deleted view with newest users and reloaded homepage. No errors and no block was there.
So everything is fine.
Thanks for the patch, @dawehner!

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/block/lib/Drupal/block/BlockPluginBag.phpundefined
@@ -57,12 +57,7 @@ protected function initializePlugin($instance_id) {
-      $module = $settings['module'];
-      // Ignore blocks belonging to disabled modules, but re-throw valid
-      // exceptions when the module is enabled and the plugin is misconfigured.
-      if (!$module || \Drupal::moduleHandler()->moduleExists($module)) {
-        throw $e;
-      }

That's completely hiding all errors now, at least watchdog_exception()?

sdboyer’s picture

@dawehner pointed me to this to make sure that it was kosher from a SCOTCH perspective. it actually kinda isn't, but the code that's already in isn't good either.

we don't ever want other systems acting on behalf blocks system and assuming something about its storage mechanism - this is (part of) why we're doing #2022897: Shift responsibility for creating unique config id/machine name off of (views) block plugins and onto BlockFormController. doing so precludes the possibility that block plugin instances might be placed & managed by any system other than core's block.module - and we're already doing exactly that in princess.

HOWEVER, that's no reason to block the fixing of this critical bug, especially because the code is no more broken in that respect by this patch than it was before. so, a followup is just fine. and here it is: #2031859: Invoke an event[s] when a plugin ID disappears.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new15.89 KB

This is the same patch as #12, but I want to know whether it fails. If it does not, I would vote to NOT do this change in this issue.

Status: Needs review » Needs work

The last submitted patch, vdc-2018493-16.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new15.86 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, vdc-2018493-18.patch, failed testing.

hussainweb’s picture

StatusFileSize
new1.72 KB
new15.99 KB
+++ b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.phpundefined
@@ -374,4 +374,22 @@ public function mergeDefaultDisplaysOptions() {
+  /**
+   * {@inheritdoc}
+   *
+   * Allow display plugins to react on deleting the entity.
+   */
+  public static function postDelete(EntityStorageControllerInterface $storage_controller, array $entities) {
+    parent::postDelete($storage_controller, $entities);
+
+    foreach ($entities as $entity) {
+      $executable = Views::executableFactory()->get($entity);
+      $executable->initDisplay();
+      foreach ($executable->displayHandlers as $display_handler) {
+        $display_handler->postDeleteView();
+      }
+    }
+  }

There is a conflict from changes in #2031519: Deleting a view does not empty it's object cache with this function. This causes installation to fail. I am rerolling a patch to fix this and first test manually. The installation succeeds after my changes. I will just run the tests locally and see if I can make some progress.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new706 bytes
new16 KB

Found the problem that caused all those warnings and exceptions. It was a very simple change, as shown in interdiff.

Now, lets see what testbots have to say.

Status: Needs review » Needs work

The last submitted patch, vdc-2018493-21.patch, failed testing.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new1.88 KB
new15.87 KB

I am fixing some of the errors with this patch. These errors were all due to incorrect usage of StorageController::load() method in the test. It was being used with the syntax of loadMultiple(), which threw all those errors.

The error I could not fix yet was:

Drupal\Component\Plugin\Exception\PluginException: The plugin (views_block:test_view_block3-block_2) did not specify an instance class. in Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (line 62 of /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php).

I am not entirely sure how to go about fixing it. The error is due to DisplayBlockTest.php, line 118 (after patch):

    // Remove the third view and ensure that the
    $view = entity_load('view', 'test_view_block3');
    $view->delete();

I got a similar error during manual testing when I deleted the view, but it was "fixed" after earlier fixes. I could not repeat it during manual testing in any case. I will post again if I find something. Meanwhile, I hope this analysis is useful.

Status: Needs review » Needs work

The last submitted patch, vdc-2018493-23.patch, failed testing.

dawehner’s picture

It seems to be basically a duplicate of #2031859: Invoke an event[s] when a plugin ID disappears

hussainweb’s picture

I just skimmed through the patch in #2031859: Invoke an event[s] when a plugin ID disappears and it looks like it might fix the problem in this issue. However, I think we could definitely use tests written in this issue. I will try out the patch there (which seems to be RTBC'd) and do a test for the problem in this issue.

catch’s picture

Component: views.module » block.module
catch’s picture

Title: FATAL error when a view with a placed block is disabled or removed » Tests for: FATAL error when a view with a placed block is disabled or removed
Priority: Critical » Major

I''ve bumped #2031859: Invoke an event[s] when a plugin ID disappears to critical. Moving this to major for tests. If this ends up not being a duplicate (apart from the tests), please bump it back to critical.

catch’s picture

Issue summary: View changes

Mve issue link

jibran’s picture

Status: Needs work » Needs review

23: vdc-2018493-23.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 23: vdc-2018493-23.patch, failed testing.

metzlerd’s picture

Category: Bug report » Task
Issue summary: View changes
Issue tags: +Triaged at DrupalCon Los Angeles 2015, +Needs issue summary update

Triage Notes:

  • Followed steps to reproduce the core issue and it is no longer an issue.
  • I searched for the fixing issue but couldn't find it.
  • The issue summary needs updating because I think what's being asked for is test coverage.
  • Changed to task because we're just asking for tests
  • Added Beta Evaluation assuming test coverage.
xjm’s picture

(Saving proposed issue credit for discussion and triage participants at LA.)

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.

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.

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.

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

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

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Closed (outdated)

I tested on Drupal 11.x, standard install, using the steps in the issue summary. I was not able to reproduce the problem. Presumably because the block is deleted when the view is deleted.