From 3c08a5b41579850ef8c7bcc474c5a2f8eeaa82eb Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Wed, 11 Apr 2018 09:20:09 +0100
Subject: [PATCH] Revert "Issue #2959316 by dww, Lendude, dawehner: Views
 argument validators that modify argument values aren't reflected in token
 replacement"

This reverts commit 26a5a2ab8a4a69298d006941b5bd348c8ff5a1bb.
---
 core/modules/views/src/ViewExecutable.php       |  9 +++------
 .../ArgumentValidatorTest.php                   |  4 ----
 .../tests/src/Kernel/ViewExecutableTest.php     | 17 +----------------
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 82504661f0ae..16b89f370e55 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -1096,8 +1096,7 @@ protected function _buildArguments() {
           $argument->is_default = TRUE;
         }
 
-        // Set the argument, which ensures that the argument is valid and
-        // possibly transforms the value.
+        // Set the argument, which will also validate that the argument can be set.
         if (!$argument->setArgument($arg)) {
           $status = $argument->validateFail($arg);
           break;
@@ -1111,11 +1110,9 @@ protected function _buildArguments() {
           $argument->query($this->display_handler->useGroupBy());
         }
 
-        // Add this argument's substitution.
+        // Add this argument's substitution
         $substitutions["{{ arguments.$id }}"] = $arg_title;
-        // Since argument validator plugins can potentially transform the value,
-        // use whatever value the argument handler now has, not the raw value.
-        $substitutions["{{ raw_arguments.$id }}"] = strip_tags(Html::decodeEntities($argument->getValue()));
+        $substitutions["{{ raw_arguments.$id }}"] = strip_tags(Html::decodeEntities($arg));
 
         // Test to see if we should use this argument's title
         if (!empty($argument->options['title_enable']) && !empty($argument->options['title'])) {
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php
index 8bee18848aed..ff251b294da4 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/argument_validator/ArgumentValidatorTest.php
@@ -37,10 +37,6 @@ protected function defineOptions() {
    * {@inheritdoc}
    */
   public function validateArgument($arg) {
-    if ($arg === 'this value should be replaced') {
-      $this->argument->argument = 'this value is replaced!';
-      return TRUE;
-    }
     return $arg == $this->options['test_value'];
   }
 
diff --git a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
index d7126b95b194..73902140520c 100644
--- a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
+++ b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php
@@ -38,7 +38,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
    *
    * @var array
    */
-  public static $testViews = ['test_destroy', 'test_executable_displays', 'test_argument_dependency'];
+  public static $testViews = ['test_destroy', 'test_executable_displays'];
 
   /**
    * Properties that should be stored in the configuration.
@@ -525,19 +525,4 @@ public function testSerialization() {
     $this->assertEquals($nid_definition_before->getPropertyDefinitions(), $nid_definition_after->getPropertyDefinitions());
   }
 
-  /**
-   * Tests if argument overrides by validators are propagated to tokens.
-   */
-  public function testArgumentValidatorValueOverride() {
-    $view = Views::getView('test_argument_dependency');
-    $view->setDisplay('page_1');
-    $view->setArguments(['1', 'this value should be replaced']);
-    $view->execute();
-    $expected = [
-      '{{ arguments.uid }}' => 'this value is replaced!',
-      '{{ raw_arguments.uid }}' => 'this value is replaced!',
-    ];
-    $this->assertEquals($expected, $view->build_info['substitutions']);
-  }
-
 }
-- 
GitLab