php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58248 class constants set to existing constants
Submitted: 2008-06-24 11:55 UTC Modified: 2008-06-25 04:20 UTC
From: asonge@php.net Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5_3 CVS-2008-06-24 (dev) OS: Linux
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: asonge@php.net
New email:
PHP Version: OS:

 

 [2008-06-24 11:55 UTC] asonge@php.net
Description:
------------
While in a namespace, setting a class constant to another constant will cause an Undefined Constant error upon instantiation on a cache hit

Reproduce code:
---------------
<?php
namespace NS;
class Foo {
    const BAR = PHP_VERSION;
    public function __construct() {
        echo "Test\n";
    }
}

new NS::Foo();


Expected result:
----------------
$ php-cgi -T 2 test.php
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

Test
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

<br />
Test

Elapsed time: 0.001163 sec


Actual result:
--------------
$ php-cgi -T 2 test.php
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

Test
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

<br />
<b>Notice</b>:  Use of undefined constant &#65533;&#65533;PHP_VERSION - assumed '&#65533;&#65533;PHP_VERSION' in <b>/home/alex/test.php</b> on line <b>10</b><br />
Test

Elapsed time: 0.001163 sec


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-24 12:56 UTC] asonge@php.net
qualifying the constant with :: (like ::PHP_VERSION) does not create an error
 [2008-06-25 03:07 UTC] gopalv82 at yahoo dot com
Just tested with current CVS + apc-3.1.x (CVS HEAD) and it doesn't crash 

PHP 5.3.0-dev (cgi-fcgi) (built: Jun 25 2008 11:59:58)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies

php-cgi  -T 2 /opt/php53/var/www/html/14225/index.php 
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

Test
X-Powered-By: PHP/5.3.0-dev
Content-type: text/html

Test
 [2008-06-25 04:01 UTC] gopalv82 at yahoo dot com
oops, too early

USE_ZEND_ALLOC=0 php-cgi  -T 2 /opt/php53/var/www/html/14225/index.php

does SEGV out
 [2008-06-25 04:20 UTC] gopalv82 at yahoo dot com
Fixed in CVS HEAD

http://news.php.net/php.pecl.cvs/10910

Please test that entire branch as thoroughly as you can :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 01 13:01:29 2024 UTC