From 7541cf5b7385c3c5d9068d5e5c53fd4cc88df028 Mon Sep 17 00:00:00 2001
From: Dorian DI RUSSO <dorian.dirusso@smile.fr>
Date: Thu, 4 Apr 2019 17:02:36 +0200
Subject: [PATCH 1/2] Issue #2888320 by Dakwamine, Rookie Rodrigo, MattDanger,
 Jim.M, davidferlay: Add support for Token and plural in Views Global result
 summary plugin

---
 ...ews.view.views_area_single_plural_test.yml | 85 +++++++++++++++++++
 .../src/Kernel/Handler/AreaResultTest.php     | 44 +++++++++-
 2 files changed, 128 insertions(+), 1 deletion(-)
 create mode 100644 core/modules/views/tests/modules/views_test_config/test_views/views.view.views_area_single_plural_test.yml

diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.views_area_single_plural_test.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.views_area_single_plural_test.yml
new file mode 100644
index 0000000000..2318de63b4
--- /dev/null
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.views_area_single_plural_test.yml
@@ -0,0 +1,85 @@
+langcode: en
+status: true
+dependencies: {  }
+id: views_area_single_plural_test
+label: ''
+module: views
+description: ''
+tag: ''
+base_table: views_test_data
+base_field: nid
+core: '8'
+display:
+  default:
+    display_options:
+      defaults:
+        fields: false
+        pager: false
+        sorts: false
+      fields:
+        id:
+          field: id
+          id: id
+          relationship: none
+          table: views_test_data
+          plugin_id: numeric
+      pager:
+        options:
+          offset: 0
+        type: none
+      sorts:
+        id:
+          field: id
+          id: id
+          order: ASC
+          relationship: none
+          table: views_test_data
+          plugin_id: numeric
+      empty:
+        title:
+          field: title
+          id: title
+          table: views
+          plugin_id: title
+          title: test_title_empty
+      header:
+        result:
+          id: result
+          table: views
+          field: result
+          relationship: none
+          group_type: group
+          admin_label: ''
+          empty: false
+          content: "start: @start | end: @end | total: @total | label: @label | per page: @per_page | current page: @current_page | current record count: @current_record_count | page count: @page_count | single text"
+          format_plural: true
+          format_plural_count: '@total'
+          format_plural_text: 'start: @start | end: @end | total: @total | label: @label | per page: @per_page | current page: @current_page | current record count: @current_record_count | page count: @page_count | plural text'
+          plugin_id: result
+    display_plugin: default
+    display_title: Master
+    id: default
+    position: 0
+  page_1:
+    display_options:
+      path: views-area-single-plural-test
+      defaults:
+        header: false
+      header:
+        result:
+          id: result
+          table: views
+          field: result
+          relationship: none
+          group_type: group
+          admin_label: ''
+          empty: false
+          content: "start: @start | end: @end | total: @total | label: @label | per page: @per_page | current page: @current_page | current record count: @current_record_count | page count: @page_count | single text"
+          format_plural: true
+          format_plural_count: '@total'
+          format_plural_text: 'start: @start | end: @end | total: @total | label: @label | per page: @per_page | current page: @current_page | current record count: @current_record_count | page count: @page_count | plural text'
+          plugin_id: result
+    display_plugin: page
+    display_title: 'Page 1'
+    id: page_1
+    position: 1
diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php
index 31e252aef2..d8bd1ebe2c 100644
--- a/core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php
@@ -16,7 +16,10 @@ class AreaResultTest extends ViewsKernelTestBase {
   /**
    * {@inheritdoc}
    */
-  public static $testViews = ['test_area_result'];
+  public static $testViews = [
+    'test_area_result',
+    'views_area_single_plural_test',
+  ];
 
   /**
    * Tests the results area handler.
@@ -72,4 +75,43 @@ public function testResultEmpty() {
     $this->assertNoRaw('<header>');
   }
 
+  /**
+   * Test the result of Result Summary.
+   */
+  public function testResultSummary() {
+    $view = Views::getView('views_area_single_plural_test');
+
+    // Test view for a single render.
+    $view->setDisplay('default');
+
+    // Add a filter that will make the result set to one.
+    $view->displayHandlers->get('default')->overrideOption('filters', [
+      'name' => [
+        'id' => 'name',
+        'table' => 'views_test_data',
+        'field' => 'name',
+        'relationship' => 'none',
+        'operator' => '=',
+        'value' => 'John',
+      ],
+    ]);
+
+    $this->executeView($view);
+    $output = $view->render();
+    $output = \Drupal::service('renderer')->renderRoot($output);
+    $this->setRawContent($output);
+    $this->assertText('start: 1 | end: 1 | total: 1 | label: views_area_single_plural_test | per page: 0 | current page: 1 | current record count: 1 | page count: 1 | single text');
+
+    // Reload the view to delete the filter.
+    $view = Views::getView('views_area_single_plural_test');
+
+    // Test view for plural render.
+    $view->setDisplay('page_1');
+    $this->executeView($view);
+    $output = $view->render();
+    $output = \Drupal::service('renderer')->renderRoot($output);
+    $this->setRawContent($output);
+    $this->assertText('start: 1 | end: 5 | total: 5 | label: views_area_single_plural_test | per page: 0 | current page: 1 | current record count: 5 | page count: 1 | plural text');
+  }
+
 }
-- 
2.17.1


From e3caf84efe46afc1d6430cf12cad3f2444cf585e Mon Sep 17 00:00:00 2001
From: Dorian DI RUSSO <dorian.dirusso@smile.fr>
Date: Fri, 5 Apr 2019 16:34:20 +0200
Subject: [PATCH 2/2] Issue #2846770 by diqidoq, marie.pinet:
 AdminRouteSubscriber incorrectly identifies paths such as
 /administration-position as admin paths

---
 .../views.view.test_area_result.yml           |  6 +++
 .../test_views/views.view.test_mini_pager.yml |  3 ++
 .../test_views/views.view.test_token_view.yml |  3 ++
 core/modules/views/views.install              | 41 +++++++++++++++++++
 4 files changed, 53 insertions(+)

diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_area_result.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_area_result.yml
index 8ca5628583..47fff48544 100644
--- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_area_result.yml
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_area_result.yml
@@ -52,6 +52,9 @@ display:
           admin_label: ''
           empty: true
           content: "start: @start | end: @end | total: @total | label: @label | per page: @per_page | current page: @current_page | current record count: @current_record_count | page count: @page_count"
+          format_plural: false
+          format_plural_count: ''
+          format_plural_text: ''
           plugin_id: result
     display_plugin: default
     display_title: Master
@@ -72,6 +75,9 @@ display:
           admin_label: ''
           empty: false
           content: "start: @start | end: @end | total: @total | label: @label | per page: @per_page | current page: @current_page | current record count: @current_record_count | page count: @page_count"
+          format_plural: false
+          format_plural_count: ''
+          format_plural_text: ''
           plugin_id: result
     display_plugin: page
     display_title: 'Page 1'
diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_mini_pager.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_mini_pager.yml
index 289f83db97..b9761a1734 100644
--- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_mini_pager.yml
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_mini_pager.yml
@@ -140,4 +140,7 @@ display:
           admin_label: ''
           empty: false
           content: 'Displaying @start - @end of @total'
+          format_plural: false
+          format_plural_count: ''
+          format_plural_text: ''
           plugin_id: result
diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml
index b2e3c7d58b..f471872ac1 100644
--- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml
@@ -214,6 +214,9 @@ display:
           admin_label: ''
           empty: true
           content: "Displaying @start - @end of @total\n\n%1-result-!1"
+          format_plural: false
+          format_plural_count: ''
+          format_plural_text: ''
           plugin_id: result
         title:
           id: title
diff --git a/core/modules/views/views.install b/core/modules/views/views.install
index 8d5d2504f5..6cb0eb89f9 100644
--- a/core/modules/views/views.install
+++ b/core/modules/views/views.install
@@ -532,3 +532,44 @@ function views_update_8500() {
     }
   }
 }
+
+/**
+ * Set new configuration on ResultSummary.
+ */
+function views_update_8800() {
+  $config_factory = \Drupal::configFactory();
+
+  foreach ($config_factory->listAll('views.view.') as $view_config_name) {
+    $changed = FALSE;
+
+    $view = $config_factory->getEditable($view_config_name);
+    $displays = $view->get('display');
+    foreach ($displays as $display_name => &$display) {
+      $area_types = ['header', 'footer', 'no_result_behavior'];
+      foreach ($area_types as $area_type) {
+        if (!empty($display['display_options'][$area_type])) {
+          foreach ($display['display_options'][$area_type] as &$area) {
+            if (isset($area['plugin_id']) && $area['plugin_id'] == 'result') {
+              if (!isset($area['format_plural'])) {
+                $area['format_plural'] = FALSE;
+                $changed = TRUE;
+              }
+              if (!isset($area['format_plural_count'])) {
+                $area['format_plural_count'] = '@total';
+                $changed = TRUE;
+              }
+              if (!isset($area['format_plural_text'])) {
+                $area['format_plural_text'] = '';
+                $changed = TRUE;
+              }
+            }
+          }
+        }
+      }
+    }
+    if ($changed) {
+      $view->set('display', $displays);
+      $view->save();
+    }
+  }
+}
-- 
2.17.1

