diff --git a/core/modules/block/tests/modules/block_test_views/test_views/views.view.test_view_block_with_context.yml b/core/modules/block/tests/modules/block_test_views/test_views/views.view.test_view_block_with_context.yml index bbd8480..9991a36 100644 --- a/core/modules/block/tests/modules/block_test_views/test_views/views.view.test_view_block_with_context.yml +++ b/core/modules/block/tests/modules/block_test_views/test_views/views.view.test_view_block_with_context.yml @@ -162,6 +162,40 @@ display: plugin_id: text_custom relationships: { } arguments: + 'null': + id: 'null' + table: views + field: 'null' + relationship: none + group_type: group + admin_label: '' + default_action: default + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: fixed + default_argument_options: + argument: foo + default_argument_skip_url: false + summary_options: + base_path: '' + count: true + items_per_page: 25 + override: false + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + must_not_be: false + plugin_id: 'null' nid: id: nid table: node_field_data diff --git a/core/modules/views/src/Plugin/Block/ViewsBlock.php b/core/modules/views/src/Plugin/Block/ViewsBlock.php index e03db23..ee3cec1 100644 --- a/core/modules/views/src/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/src/Plugin/Block/ViewsBlock.php @@ -25,16 +25,24 @@ public function build() { $this->view->display_handler->preBlockBuild($this); $args = []; - foreach ($this->getContexts() as $context_name => $context) { + foreach ($this->view->display_handler->getHandlers('argument') as $argument_name => $argument) { /** @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase $argument */ - if (($argument = $this->view->display_handler->getHandler('argument', $context_name)) && ($value = $context->getContextValue())) { - if ($value instanceof EntityInterface) { - $value = $value->id(); + if (!empty($this->context[$argument_name])) { + if (($value = $this->context[$argument_name]->getContextValue())) { + if ($value instanceof EntityInterface) { + $value = $value->id(); + } + $args[] = $value; + } + elseif ($argument->options['default_action'] == 'ignore') { + $args[] = $argument->options['exception']['value']; + } + else { + $args[] = NULL; } - $args[] = $value; } - elseif ($argument->options['default_action'] == 'ignore') { - $args[] = $argument->options['exception']['value']; + else { + $args[] = NULL; } }