php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77643 PHP Warning: Can't preload class Zend\Db\Sql\Insert with unresolved constants
Submitted: 2019-02-21 01:19 UTC Modified: 2019-02-21 09:49 UTC
From: mberchtold at gmail dot com Assigned: nikic (profile)
Status: Closed Package: opcache
PHP Version: master-Git-2019-02-21 (snap) OS: Windows 10 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mberchtold at gmail dot com
New email:
PHP Version: OS:

 

 [2019-02-21 01:19 UTC] mberchtold at gmail dot com
Description:
------------
I'm trying to preload zend framework 3. A lot of the following warnings are reported and the class is not preloaded:
PHP Warning:  Can't preload class Zend\Db\Sql\Insert with unresolved constants

When I inspect the Zend\Db\Insert class, there are no undefined constants. 
Preloading only the file itself does not issue any warnings, only after all the dependent classes are preloaded.

I could not figure out a minimal reproducible example, other than preloading some files from zend\db.


Test script:
---------------
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.preload={PWD}/preload_undef_const_3.inc

preload_undef_const_3.inc:

<?php
$basedirectory = 'C:/test/';
// dependent classes
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Adapter/Platform/PlatformInterface.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/SqlInterface.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/AbstractSql.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/PreparableSqlInterface.php');
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/AbstractPreparableSql.php');
// actual class
opcache_compile_file($basedirectory . 'vendor/zendframework/zend-db/src/Sql/Insert.php');


Expected result:
----------------
No warning

Actual result:
--------------
PHP Warning:  Can't preload class Zend\Db\Sql\Insert with unresolved constants

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-21 09:49 UTC] nikic@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: nikic
 [2019-02-21 09:49 UTC] nikic@php.net
Here is a minimal repro:

<?php
  
class Foo {
    protected $prop;
}

class Bar extends Foo {
    protected $prop = self::FOOBAR;
    const FOOBAR = 42;
}

The problem is that the constant is resolved against the wrong class, because we're reusing a property slot from the parent.
 [2019-02-21 10:01 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=6b110b151ddb2eb123407131476aa510b73f54d0
Log: Fixed bug #77643
 [2019-02-21 10:01 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 21:03:16 2021 UTC