php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80950 Variables become null in if statements
Submitted: 2021-04-12 13:20 UTC Modified: 2021-04-12 14:04 UTC
From: sycxyc at yandex dot com Assigned:
Status: Closed Package: opcache
PHP Version: 7.4.16 OS: Linux
Private report: No CVE-ID: None
 [2021-04-12 13:20 UTC] 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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-12 14:04 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2021-04-12 14:04 UTC] 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 14:07 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/a1fdfa700bfefa347f0347c0fe49dd34badf9ac0
Log: Fixed bug #80950
 [2021-04-12 14:07 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC