php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79055 Typed property become unknown with OPcache file cache
Submitted: 2020-01-02 10:01 UTC Modified: 2020-01-02 14:04 UTC
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:6 (100.0%)
Same OS:6 (100.0%)
From: kentaro at ranvis dot com Assigned:
Status: Closed Package: opcache
PHP Version: 7.4Git-2020-01-02 (Git) OS: Linux
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 - 25 = ?
Subscribe to this entry?

 
 [2020-01-02 10:01 UTC] kentaro at ranvis dot com
Description:
------------
When OPcache loads cached script from file,
PHP fails to identify typed property specifier in the loaded class, and reports it typed as "unknown or null".

Fails on PHP-7.4 (8d2b20db58849d1f54303f66656a3776456cbe95),
while succeeds on master (a9c04aee67a1d787101c967b8980d679b1714bf0).

I'm sorry to bother if it's going to be fixed in 7.4 branch too.

Test script:
---------------
mkdir /dev/shm/opcache
./php -n -d extension_dir=modules/ -d zend_extension=opcache -d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.file_cache=/dev/shm/opcache main.php
# run above script twice

[main.php]
<?php
opcache_reset();
spl_autoload_register(function ($cls) {
    echo "$cls\n";
    require_once(__DIR__ . "/$cls.php");
});
try {
    $c = new C();
    $x = new X($c);
    echo "Success\n";
} catch (Error $e) {
    echo $e->getMessage() . "\n";
}

[C.php]
<?php
class C {}

[X.php]
<?php
class X {
    private C $c;
    public function __construct(C $c) {
        $this->c = $c;
    }
}


Expected result:
----------------
$ ./php ...
C
X
Success
$ ./php ...
C
X
Success


Actual result:
--------------
$ ./php ...
C
X
Success
$ ./php ...
C
X
Typed property X::$c must be unknown or null, C used


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-02 12:12 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2020-01-02 12:12 UTC] nikic@php.net
Also seeing some serious map_ptr issues when mixing file_cache and shm.
 [2020-01-02 14:55 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8abb2ced399c6869c89783425cfa9483b9ef60cb
Log: Fixed bug #79055
 [2020-01-02 14:55 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 09:01:31 2024 UTC