php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80488 ReflectionParameter->getDefaultValue() throws for dbase_create()
Submitted: 2020-12-06 17:37 UTC Modified: 2020-12-06 23:25 UTC
From: tandre@php.net Assigned: cmb (profile)
Status: Closed Package: dbase (PECL)
PHP Version: 8.0.0 OS:
Private report: No CVE-ID: None
 [2020-12-06 17:37 UTC] tandre@php.net
Description:
------------
https://svn.php.net/viewvc/pecl/dbase/trunk/dbase.stub.php?view=markup references the C constant name `"DBH_TYPE_NORMAL"`, but should instead reference the PHP constant `"DBASE_TYPE_NORMAL"`

in dbase.c:
`REGISTER_LONG_CONSTANT("DBASE_TYPE_DBASE",  DBH_TYPE_NORMAL, CONST_CS | CONST_PERSISTENT);`

ERROR: Error: Undefined constant "DBH_TYPE_NORMAL" is seen when calling ReflectionParameter->getDefaultValue() for the parameter of `dbase_create`

See https://www.php.net/manual/en/dbase.constants.php - possibly outdated, but 

Test script:
---------------
var_export((new ReflectionFunction('dbase_create'))->getParameters()[2]->getDefaultValue());
/*
Warning: Uncaught Error: Undefined constant "DBH_TYPE_NORMAL" in php shell code:1
Stack trace:
#0 php shell code(1): ReflectionParameter->getDefaultValue()
#1 {main}
  thrown in php shell code on line 1
*/

Expected result:
----------------
Returns the default value

Actual result:
--------------
Throws an Error

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-06 17:40 UTC] tandre@php.net
I misread the code - it should instead reference the PHP constant `"DBASE_TYPE_DBASE"` as mentioned in https://www.php.net/manual/en/dbase.constants.php, not NORMAL
 [2020-12-06 17:40 UTC] tandre@php.net
-Assigned To: +Assigned To: cmb
 [2020-12-06 23:20 UTC] cmb@php.net
-Status: Assigned +Status: Verified
 [2020-12-06 23:20 UTC] cmb@php.net
Thanks for reporting!
 [2020-12-06 23:21 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=351938
Log: Fix #80488: ReflectionParameter->getDefaultValue() throws for dbase_create()
 [2020-12-06 23:25 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2021-04-06 10:18 UTC] git@php.net
Automatic comment on behalf of 
Revision: https://github.com/php/pecl-database-dbase/commit/86b36d54af1b9f7949f4b4a5de0c992875125453
Log: Fix #80488: ReflectionParameter->getDefaultValue() throws for dbase_create()
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC