Bug #80950 [Ver->Csd]: Variables become null in if statements

From: Date: Mon, 12 Apr 2021 14:07:23 +0000
Subject: Bug #80950 [Ver->Csd]: Variables become null in if statements
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233366@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80950&edit=1

 ID:                 80950
 Updated by:         git@php.net
 Reported by:        sycxyc at yandex dot com
 Summary:            Variables become null in if statements
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            opcache
 Operating System:   Linux
 PHP Version:        7.4.16
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/a1fdfa700bfefa347f0347c0fe49dd34badf9ac0
Log: Fixed bug #80950


Previous Comments:
------------------------------------------------------------------------
[2021-04-12 14:04:42] nikic@php.net

The func info on 7.4 incorrectly specifies that curl_exec() cannot return true. This was fixed in
8.0 as the func info was removed there (and uses the correct stub information instead).

------------------------------------------------------------------------
[2021-04-12 13:20:10] sycxyc at yandex dot com

Description:
------------
When opcache is enabled, unexpected results will occur when executed twice or more.

Test script:
---------------
<?php
function foo(){
	$ch=curl_init('example.com');
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,false);
	ob_start();
	$data=curl_exec($ch);
	ob_end_clean();
	var_dump('out1',$data);
	if(true===$data){
		if(null===$data){
			var_dump('in1',$data);
		}
	}
	var_dump('out2',$data);
}
foo();


Expected result:
----------------
string(4) "out1"
bool(true)
string(4) "out2"
bool(true)

Actual result:
--------------
string(4) "out1"
bool(true)
string(3) "in1"
NULL
string(4) "out2"
bool(true)



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80950&edit=1


Thread (3 messages)

« previous php.bugs (#233366) next »