From 255a33f541040c26bd08a8dbb1b82dbb3c032378 Mon Sep 17 00:00:00 2001 From: webchick Date: Thu, 6 Feb 2014 23:15:09 -0800 Subject: [PATCH] Issue #1967124 by damiankloip, dawehner | xjm: Bulk action views array to string conversion when there are no results. --- .../lib/Drupal/action/Tests/BulkFormTest.php | 5 +++++ .../config/views.view.test_bulk_form.yml | 21 +++++++++++++++++++ core/modules/views/views.theme.inc | 11 ++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php index 0e6f98d72dd..a59d294e0f3 100644 --- a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php +++ b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php @@ -35,6 +35,11 @@ class BulkFormTest extends WebTestBase { * Tests the bulk form. */ public function testBulkForm() { + // First, test an empty bulk form with the default style plugin to make sure + // the empty region is rendered correctly. + $this->drupalGet('test_bulk_form_empty'); + $this->assertText(t('This view is empty.'), 'Empty text found on empty bulk form.'); + $nodes = array(); for ($i = 0; $i < 10; $i++) { // Ensure nodes are sorted in the same order they are inserted in the diff --git a/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml b/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml index fd41bc47c8f..b2f66ed46cc 100644 --- a/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml +++ b/core/modules/action/tests/action_bulk_test/config/views.view.test_bulk_form.yml @@ -150,6 +150,27 @@ display: position: null display_options: path: test_bulk_form + page_2: + display_plugin: page + id: page_2 + display_title: Page + position: null + display_options: + path: test_bulk_form_empty + defaults: + style: false + empty: false + style: + type: default + empty: + area: + id: area + table: views + field: area + empty: true + content: 'This view is empty.' + plugin_id: text_custom + provider: views base_field: nid status: true module: views diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 6c6cd0a1f47..754fe8e205d 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -133,8 +133,15 @@ function template_preprocess_views_view(&$variables) { if (views_view_has_form_elements($view)) { // Copy the rows so as not to modify them by reference when rendering. $rows = $variables['rows']; - $rows = drupal_render($rows); - $output = !empty($rows) ? $rows : $variables['empty']; + // Only render row output if there are rows. Otherwise, render the empty + // region. + if (!empty($rows)) { + $output = drupal_render($rows); + } + else { + $empty = $variables['empty']; + $output = drupal_render($empty); + } $container = \Drupal::getContainer(); $form_object = new ViewsForm($container->get('controller_resolver'), $container->get('url_generator'), $container->get('request'), $view->storage->id(), $view->current_display);