php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48629 get_defined_constants() ignores categorize parameter
Submitted: 2009-06-21 19:38 UTC Modified: 2009-06-22 00:03 UTC
From: rockyroad29 at free dot fr Assigned:
Status: Closed Package: Arrays related
PHP Version: 5.2CVS-2009-06-21 (snap) OS: linux
Private report: No CVE-ID:
 [2009-06-21 19:38 UTC] rockyroad29 at free dot fr
Description:
------------
  get_defined_constants(FALSE)

returns the same categorized array as

  get_defined_constants(TRUE)

----
Hmmm, I just realized that 
  get_defined_constants()

returns the one-dimensional array I expected.

Anyway that's still a bug.



Reproduce code:
---------------
<?php
echo 'php version: ', phpversion(), "\n";
echo 'Testing the function: get_defined_constants([ bool $categorize  ] )' , "\n";

$constants_T = get_defined_constants(TRUE);
$categs = array_keys($constants_T);
echo "First category: $categs[0]\n";

$constants_F = get_defined_constants(FALSE);
$names = array_keys($constants_F);

$n = count(array_diff($constants_T, $constants_F));
if ($n) {
  echo "$n differences found when changing the categorize parameter", "\n";
  echo "THE BUG IS PROBABLY ABSENT\n";
  echo "First constant name: $names[0]\n";  
} else {
  echo "no difference found when changing the categorize parameter", "\n";
  echo "A constant name is expected here, I get a category: '$names[0]'\n";  
  echo "THE BUG IS PRESENT\n";
}

Expected result:
----------------
$ php constants.php
php version: xxxx
Testing the function: get_defined_constants([ bool $categorize  ] )
First category: internal
xxx differences found when changing the categorize parameter
THE BUG IS PROBABLY ABSENT
First constant name: E_ERROR


Actual result:
--------------
I tested two versions, on Ubuntu "Jaunty":

$ uname -a
Linux claddagh 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux

$ /usr/bin/php constants.php
php version: 5.2.6-3ubuntu4.1
Testing the function: get_defined_constants([ bool $categorize  ] )
First category: internal
no difference found when changing the categorize parameter
A constant name is expected here, I get a category: 'internal'
THE BUG IS PRESENT

$ /usr/local/bin/php constants.php
php version: 5.2.11-dev
Testing the function: get_defined_constants([ bool $categorize  ] )
First category: internal
no difference found when changing the categorize parameter
A constant name is expected here, I get a category: 'internal'
THE BUG IS PRESENT

$ /usr/local/bin/php -version
PHP 5.2.11-dev (cli) (built: Jun 21 2009 20:21:29) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-22 00:03 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 00:01:21 2014 UTC