[php-src] Issue #11134: match expression matches first expression within a function/method using apache2handler sapi

From: Date: Wed, 26 Apr 2023 07:38:52 +0000
Subject: [php-src] Issue #11134: match expression matches first expression within a function/method using apache2handler sapi
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244271@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11134 Author: myersem2 ### Description This issue is visible on **Apache/2.4.52**, the cli works as expected however something with the sapi (_apache2handler_) gives you bad results. If you run the following code you will get the correct results on the first page load however if you refresh the page you will get the document incorrect matches below. The following code: <test.php> ```php <?php // TEST-1: Functioning as expected - PASS $subj = $unset_variable ?? null; $result = match ($subj) { 'Some-Text' => 'Incorect-Match-1', 'Other-Text' => 'Incorect-Match-2', default => 'Expected-Result', }; var_dump($result); // string 'Expected-Result' (length=15) // TEST-2: Incorrectly matches first expression - FAILS function testFunction1() { $subj = $unset_variable ?? null; $result = match ($subj) { 'Some-Text' => 'Incorect-Match-1', 'Other-Text' => 'Incorect-Match-2', default => 'Expected-Result', }; var_dump($result); //string 'Incorect-Match-1' (length=16) } testFunction1(); // TEST-3: Incorrectly matches first expression - FAILS class TestClass1 { public function __construct() { $subj = $unset_variable ?? null; $result = match ($subj) { 'Some-Text' => 'Incorect-Match-1', 'Other-Text' => 'Incorect-Match-2', default => 'Expected-Result', }; var_dump($result); //string 'Incorect-Match-1' (length=16) } } $test_class = new TestClass1(); // TEST-4: Functioning as expected - PASS function testFunction2() { $subj = $unset_variable ?? null; $result = match ($subj) { 'Some-Text' => 'Incorect-Match-1', //'Other-Text' => 'Incorect-Match-2', default => 'Expected-Result', }; var_dump($result); //string 'Incorect-Match-1' (length=16) } testFunction2(); // TEST-5: Functioning as expected - PASS class TestClass2 { public function __construct() { $subj = $unset_variable ?? null; $result = match ($subj) { 'Some-Text' => 'Incorect-Match-1', //'Other-Text' => 'Incorect-Match-2', default => 'Expected-Result', }; var_dump($result); //string 'Incorect-Match-1' (length=16) } } $test_class = new TestClass2(); ### PHP Version PHP 8.1.2 ### Operating System Ubuntu 22.04.1

« previous php.bugs (#244271) next »