TypeError: Argument 1 passed to                                                         [error]
Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber::Drupal\views\EventSubscriber\{closure}()
must be of the type array, null given, called in
/var/www/html/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php
on line 240 in
Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber->Drupal\views\EventSubscriber\{closure}()
(line 295 of
/var/www/html/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php)

Comments

gmaka created an issue. See original summary.

gmaka’s picture

StatusFileSize
new1.06 KB

Attached patch fixes the issue.

gmaka’s picture

StatusFileSize
new842 bytes

#2 was a bad patch, this is the corrected one.

mudassar774’s picture

StatusFileSize
new858 bytes

#3 The patch was not applied for to 8.7.x branch

andileco’s picture

Patch #4 worked for me for updating from 8.6.(don't remember) to 8.7.3.

lendude’s picture

Status: Active » Postponed (maintainer needs more info)
+++ b/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php
@@ -276,7 +276,9 @@ protected function processHandlers(array $all_views, callable $process) {
+            if (is_array($handler_config)) {

Why would this not be an array? That sounds like broken config. So are we sure this is not just hiding a valid failing scenario?

gmaka’s picture

Lendude,
I am not sure, I just ran into this again on a different project after 10 months and it looks like a whole lot are encountering this.

Take a look at this issue.

When the update fails with the the typeError mentioned in this issue, the subsequent updb's will fail with this issue https://www.drupal.org/project/drupal/issues/3039586

It looks like I may have been able to piece the two issues together. In any event, patch #4 applies for me and fixes all my woes.

Moving on.

gmaka’s picture

Lendude,

You're correct, In my case it was failing because of a Broken/missing handler in a view. Removing that missing handler allowed the update to run cleanly without the need for this patch.

Thanks!

gmaka’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
gmaka’s picture

plach’s picture

Priority: Normal » Major
Status: Closed (works as designed) » Active

I think we should reopen this: we cannot risk to break the update process because a view cannot be resaved, we already committed similar fixes in the past weeks.

plach’s picture

Title: Error when running database update. » ViewsEntitySchemaSubscriber may fail when a view as a broken handler
plach’s picture

Title: ViewsEntitySchemaSubscriber may fail when a view as a broken handler » ViewsEntitySchemaSubscriber may fail when a view has a broken handler
plach’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new3.32 KB

This tries a slightly different approach, since each callback might decide to handle a NULL value differently.

plach’s picture

Version: 8.6.x-dev » 8.7.x-dev
amateescu’s picture

It looks like we could use the view from core/modules/views/tests/modules/views_test_config/test_views/views.view.test_view_broken.yml for the test coverage here.

plach’s picture

Issue tags: -Needs tests
StatusFileSize
new2.28 KB
new5.38 KB

This should provide test coverage, the test-only patch is the interdiff.

I could not rely on the broken view suggested by @amateescu because that does not return a NULL handler and it seems it is actually impossible to save a test view with a NULL handler value, so I had to work around that.

plach’s picture

The test-only patch was broken, reposting it.

plach’s picture

Fixed a couple of PHP docs issues.

plach’s picture

StatusFileSize
new1.23 KB

... and the interdiff.

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

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me! Thanks for sticking with this, @plach :)

amateescu’s picture

Issue tags: +8.7.0 update

It looks like this could fix a lot of the problems for people updating to Drupal 8.7.x (based on #7), so tagging accordingly.

  • catch committed bedbaf7 on 8.8.x
    Issue #3006815 by plach, gmaka, mudassar774, amateescu, Lendude:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.8.x and cherry-picked to 8.7.x, thanks!

  • catch committed a8de3c8 on 8.7.x
    Issue #3006815 by plach, gmaka, mudassar774, amateescu, Lendude:...

Status: Fixed » Closed (fixed)

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