From 7527a85461fe3db0ccff731eff93a1873d249359 Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Mon, 10 Jul 2023 08:52:21 +1000
Subject: [PATCH] Issue #3338973 by Lendude, cbfannin, ericdsd, marc.groth:
 Deprecated: preg_split(): Passing null in argument_validator

(cherry picked from commit c4bbc93c2c415ec9fcf41a364a441ed9b6dc13bc)
---
 .../views/src/Plugin/views/argument_validator/Entity.php       | 2 +-
 .../tests/src/Unit/Plugin/argument_validator/EntityTest.php    | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/modules/views/src/Plugin/views/argument_validator/Entity.php b/core/modules/views/src/Plugin/views/argument_validator/Entity.php
index ba0bb219623d..1954a10c56c0 100644
--- a/core/modules/views/src/Plugin/views/argument_validator/Entity.php
+++ b/core/modules/views/src/Plugin/views/argument_validator/Entity.php
@@ -177,7 +177,7 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$opti
   public function validateArgument($argument) {
     $entity_type = $this->definition['entity_type'];
 
-    if ($this->multipleCapable && $this->options['multiple']) {
+    if ($this->multipleCapable && $this->options['multiple'] && isset($argument)) {
       // At this point only interested in individual IDs no matter what type,
       // just splitting by the allowed delimiters.
       $ids = array_filter(preg_split('/[,+ ]/', $argument));
diff --git a/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php b/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
index b7ccfa001980..0b021fd61d88 100644
--- a/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
@@ -129,6 +129,7 @@ public function testValidateArgumentNoAccess() {
 
     $this->assertFalse($this->argumentValidator->validateArgument(3));
     $this->assertFalse($this->argumentValidator->validateArgument(''));
+    $this->assertFalse($this->argumentValidator->validateArgument(NULL));
 
     $this->assertTrue($this->argumentValidator->validateArgument(1));
     $this->assertTrue($this->argumentValidator->validateArgument(2));
@@ -249,6 +250,8 @@ public function testValidateArgumentMultiple() {
     $this->assertFalse($this->argumentValidator->validateArgument('1,2'));
     $this->assertFalse($this->argumentValidator->validateArgument('1+2'));
 
+    $this->assertFalse($this->argumentValidator->validateArgument(NULL));
+
     $options = [];
     $options['access'] = TRUE;
     $options['bundles'] = [];
-- 
GitLab