I was doing view import, In between site shown "The website encountered an unexpected error. Please try again later."

While looking to error logs in web server it gives,
Error: Unsupported operand types in Drupal\views\Entity\View->mergeDefaultDisplaysOptions() (line 472 of modules/views/src/Entity/View.php).

Comments

shafeequeaslam created an issue. See original summary.

mustanggb’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 8.x-3.x-dev » 8.3.x-dev
Component: Miscellaneous » views.module
Priority: Critical » Minor
Status: Active » Postponed (maintainer needs more info)
Issue tags: -#views #displayoptions #view.php #drupal #drupal8
Senthil Kumar Kumaran’s picture

Priority: Minor » Critical

This happened on a production deployment. This is a very important feature of Drupal 8 and need to be addressed on priority.

cilefen’s picture

Priority: Critical » Major

Priorities are defined: https://www.drupal.org/core/issue-priority

It seems there has been no progress because insufficient information was provided.

handkerchief’s picture

StatusFileSize
new1.12 KB

Drupal 8.6.14

I received this error message after importing some configs:
Error: Unsupported operand types in Drupal\views\Entity\View->mergeDefaultDisplaysOptions() (line 483 of core/modules/views/src/Entity/View.php).

I changed the View.php file a bit, then I received the error message:
Plugin ID 'default' was not found.

I changed the View.php again and no error message appears again.

handkerchief’s picture

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

Correction: The drupal warning message: "Plugin ID 'default' was not found." appears sometimes on the website. But no other log messages or something. So I don't know what exactly is missing. But the website and the views works fine. But without my patch, the fatal error comes back.

See also:
#2802255: Warning message "Plugin ID 'default' was not found.” seen after update to Group 8beta3

cilefen’s picture

Status: Postponed (maintainer needs more info) » Needs review
daffie’s picture

@hankerchief: Could you post the view that when importing, causes the mentioned error.

lordzik’s picture

I got the same error. This this a view i'm trying to import using config manager (single element):

uuid: 0f1c0577-179b-4b22-b0ac-ba75603f1266
langcode: pl
status: true
dependencies:
  config:
    - field.storage.node.field_banner_front
    - field.storage.node.field_banner_link
    - node.type.banner_front
  module:
    - image
    - link
    - node
    - slick_views
    - user
id: banery2
label: 'Banery front'
module: views
description: 'Banners'
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
  default:
    display_plugin: default
    id: default
    display_title: Master
    position: 0
    display_options:
      access:
        type: perm
        options:
          perm: 'access content'
      cache:
        type: tag
        options: {  }
      query:
        type: views_query
        options:
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_comment: ''
          query_tags: {  }
      exposed_form:
        type: basic
        options:
          submit_button: Apply
          reset_button: false
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
      pager:
        type: some
        options:
          items_per_page: 0
          offset: 0
      style:
        type: slick
        options:
          vanilla: false
          optionset: banery
          skin: grid
          layout: ''
          caption:
            field_banner_link: '0'
            field_banner_front: '0'
          optionset_thumbnail: ''
          skin_thumbnail: ''
          thumbnail_position: ''
          grid: null
          grid_medium: 4
          grid_small: null
          visible_items: null
          preserve_keys: false
          image: ''
          thumbnail: ''
          overlay: field_banner_front
          title: ''
          link: ''
          class: ''
          id: ''
          override: true
          overridables:
            arrows: arrows
            autoplay: autoplay
            infinite: infinite
            dots: '0'
            draggable: '0'
            mouseWheel: '0'
            randomize: '0'
            variableWidth: '0'
          cache: 0
          current_view_mode: block_1
          thumbnail_effect: ''
      row:
        type: fields
      fields:
        field_banner_link:
          id: field_banner_link
          table: node__field_banner_link
          field: field_banner_link
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: true
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: uri
          type: link
          settings:
            trim_length: 80
            url_only: false
            url_plain: false
            rel: '0'
            target: '0'
          group_column: ''
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          plugin_id: field
        field_banner_front:
          id: field_banner_front
          table: node__field_banner_front
          field: field_banner_front
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: '<a href={{ field_banner_link }}>{{ field_banner_front }}</a>'
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: target_id
          type: image
          settings:
            image_style: ''
            image_link: ''
          group_column: ''
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          plugin_id: field
      filters:
        status:
          value: '1'
          table: node_field_data
          field: status
          plugin_id: boolean
          entity_type: node
          entity_field: status
          id: status
          expose:
            operator: ''
          group: 1
        type:
          id: type
          table: node_field_data
          field: type
          relationship: none
          group_type: group
          admin_label: ''
          operator: in
          value:
            banner_front: banner_front
          group: 1
          exposed: false
          expose:
            operator_id: ''
            label: ''
            description: ''
            use_operator: false
            operator: ''
            identifier: ''
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
            reduce: false
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
          entity_type: node
          entity_field: type
          plugin_id: bundle
      sorts:
        created:
          id: created
          table: node_field_data
          field: created
          order: DESC
          entity_type: node
          entity_field: created
          plugin_id: date
          relationship: none
          group_type: group
          admin_label: ''
          exposed: false
          expose:
            label: ''
          granularity: second
      title: 'Banery front'
      header: {  }
      footer: {  }
      empty: {  }
      relationships: {  }
      arguments: {  }
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - 'user.node_grants:view'
        - user.permissions
      tags:
        - 'config:field.storage.node.field_banner_front'
        - 'config:field.storage.node.field_banner_link'
  block_1:
    display_plugin: block
    id: block_1
    display_title: Block
    position: 1
    display_options:
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - 'user.node_grants:view'
        - user.permissions
      tags:
        - 'config:field.storage.node.field_banner_front'
        - 'config:field.storage.node.field_banner_link'

Patch from #5 works and brings whole page back to life.

pandaski’s picture

I am having the same issue with Drupal version 8.7.6 after I imported a single configuration via the interface.

The website encountered an unexpected error. Please try again later.
Error: Unsupported operand types in Drupal\views\Entity\View->mergeDefaultDisplaysOptions() (line 485 of core/modules/views/src/Entity/View.php).
pandaski’s picture

Version: 8.6.x-dev » 8.8.x-dev
StatusFileSize
new599 bytes

Problem/Motivation

After troubleshooting, there are two issues for this error:

  1. The config manager cannot validate the single configuration deeply which leads to the `$options has a 'null'`
  2. The public function mergeDefaultDisplaysOptions has no check to `$options`

Steps to reproduce this issue

  1. Fresh install the Drupal 8.8.0-dev with a Minimal profile;
  2. Enable `views` and `config` modules
  3. Goto `admin/config/development/configuration/single/import` and import the configuration from the following example (Set the `Configuration type` as `view`)
  4. a 500 error is triggered without the patch

Test single item configuration:

uuid: 196b1ade-7d2a-487f-858f-bd9f6c566a15
langcode: en
status: true
dependencies:
  module:
    - system
    - views
id: views_block__profile_header_block_2
region: logo
weight: -7
provider: null
plugin: 'views_block:profile_header-block_2'
settings:
  id: 'views_block:profile_header-block_2'
  label: ''
  provider: views
  label_display: '0'
  views_label: ''
  items_per_page: none
  context_mapping: {  }
visibility:
  request_path:
    id: request_path
    pages: "<front>\r\n/minister/*"
    negate: false
    context_mapping: {  }

Proposed resolution

Add a quick check to public function `mergeDefaultDisplaysOptions`

Please check the patch for details

rensingh99’s picture

Status: Needs review » Reviewed & tested by the community

Hi

I have reviewed the patch #11 and it worked as designed.

Below is my review:

1) I have installed Drupal 8.9.x with minimal profile.

2) I have deleted "Who's new" view from newly installed Drupal, And export "Who's new" view from another Drupal website.

3) After that I have tried to import "Who's new" view without applying patch then i got this error.

Error: Unsupported operand types in Drupal\views\Entity\View->mergeDefaultDisplaysOptions() (line 490 of C:\xampp\htdocs\drupal_test\core\modules\views\src\Entity\View.php)

4) When i import the "Who's new" view after applying patch. It's working great without any error.

Thanks,
Ren

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks for filing this bug report and for fixing it. Bug fixing is very valuable. However in order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:

  1. https://www.drupal.org/docs/8/testing
  2. https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.7.x
tepelena’s picture

I am having a problem where we get "Plugin ID 'page_1' was not found." and the Views UI can not be accessed at all.

medinasod’s picture

Confirming the patch in comment #11 worked for me. Thank you, pandaski!

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.

hidayat365’s picture

I'm using 9.1.2 and got this message after importing views from another site. patch #11 works for me.

Could be this patch get merge to Drupal core?

ssankarsiva’s picture

#11 Patch worked for me. Got error after importing a single view config.

charlie59’s picture

Can confirm this is still an issue with drupal 8.9.18 and that the patch in #11 works.

avpaderno’s picture

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8.9.x is in security support only.

sgroundwater’s picture

I was just moving some sites between hosts when I hit this error. I'm on 9.2.9, the patch in #11 set me straight, but I needed to remember to apply it after I moved the site. Patching core is no good. If acceptable, it'd be nice to get this committed. - Thanks

danflanagan8’s picture

As explained in #23, there's no way to get this committed without first adding test coverage.

I'm interested in writing tests for this issue, but there are still no clear steps to reproduce. The comment in #11 comes close, but I don't understand why we would be importing the configuration for a Block as if it's the configuration for a View. That doesn't seem like a valid case to be testing against. Surely something like that should not simply be ignored, which is what the patch does.

What is a real world situation where this error results from "normal" behavior?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

danflanagan8’s picture

I wonder if this issue isn't a duplicate of #2008708: Validate views during import.

The steps to reproduce seem to boil down to "Import invalid Views configuration".

sgroundwater’s picture

I just upped to from 9.2.x to 9.3.0 and hit this issue. I may have applied this patch against my previous 9.2.x., I can't remember. Hacking core is bad, but if it fixes a white screen I'm all for it. Thanks for the patch in #11, this set me straight for the short-term.

FYI, drush wd-show:
Error: Unsupported operand types in Drupal\views\Entity\View->mergeDefaultDisplaysOptions() (line 436 ...

drush updb:
... In ProcessBase.php line 171:
Unable to decode output into JSON: Syntax error
Error: Unsupported operand types in Drupal\views\Entity\View->mergeDefaultDisplaysOptions() (line 436 ... /web/core/modules/view
s/src/Entity/View.php).

murilohp’s picture

StatusFileSize
new4.12 KB
new3.99 KB

Hey everyone, I tried to write some tests based on the patch #11, the first test is a functional test to simulate the scenario reported in #11. The other test is a unit test to validate the View::mergeDefaultDisplaysOptions.

I'll move this issue to needs review, if you have any other idea for testing, or something to improve, please let me know.

Thanks!

murilohp’s picture

Status: Needs work » Needs review
danflanagan8’s picture

Status: Needs review » Needs work

Hi @murilohp,
Thanks for the tests! Since this issue is a bug report, it is important that we have a test-only patch that demonstrates that your new or updated test triggers the bug.

In other words, can you re-post your patch but without the fix from #11? You can included FAIL or test-only to the patch name so everyone knows that a failure is expected.

Setting back to NW for that.

murilohp’s picture

Hey @danflanagan8! Thanks for the response and the explanation, the following patch now is a test only patch. For this scenario, I don't think an interdiff is necessary, but if you want, I can upload the interdiff.

Thanks!

murilohp’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
danflanagan8’s picture

Status: Needs work » Needs review
Issue tags: +Needs steps to reproduce, +Needs issue summary update

Hi @apaderno! I believe this issue was set to NR to get a review of the fail test(s) in #29. I'm going to set back to NR for that.

That said, this one definitely needs lots of work including an IS update with steps to reproduce. I'l add those tags. In #24 I suggest that this issue may be a duplicate of an older issue. It would be nice for someone to investigate that possibility before spending a ton of time on this issue.

codesmith’s picture

This just hit me. I imported a Webform containing an embedded view that was missing on the site. Resulted in WSOD on all urls. Patch in #11 allowed pages to load again.

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.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs Review Queue Initiative

Based on #32 moving to PNMI.

Did not test

mxr576’s picture

Version: 9.5.x-dev » 11.x-dev
smustgrave’s picture

Issue tags: +Bug Smash Initiative

Following up if anyone can update IS with steps, if no follow up could close out in 3 months.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there's been no follow up or summary update going to close out. Please re-open if still experiencing this and update summary using full template.

Thanks all.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.