php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58319 OCI-LOB invalid character in Class name
Submitted: 2008-08-19 06:37 UTC Modified: 2020-10-27 10:11 UTC
Votes:6
Avg. Score:4.3 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:3 (50.0%)
From: kevinpgrant at yahoo dot co dot uk Assigned: cmb (profile)
Status: Closed Package: OCI8 related
PHP Version: 5.2.5 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kevinpgrant at yahoo dot co dot uk
New email:
PHP Version: OS:

 

 [2008-08-19 06:37 UTC] kevinpgrant at yahoo dot co dot uk
Description:
------------
checking if an IN OUT CLOB input parameter returned from Oracle is an instanceof OCI-Lob fails, because of the invalid hyphen character in the class/object name!

We have to use workarounds involving get_class($mylob) == 'OCI-Lob' instead, or use the deprecated 'is_a' check.

Reproduce code:
---------------
$sql = "insert into table (field1, field2) values (field1 = 'value',
 field2 = empty_clob()) returning field2 into :field2";
OCIParse($conn, $sql);
$clob = OCINewDescriptor($conn, OCI_D_LOB);

// check $clob is of type 'OCI-Lob' here

OCIBindByName($stmt, ":field2", &$clob, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$clob->save("some text");
OCICommit($conn);

Expected result:
----------------
should return true/false when testing fo instanceof OCI-Lob (suggest using OCI_Lob instead ...?)

Actual result:
--------------
php barfs due to '-' character

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-19 06:40 UTC] tony at daylessday dot org
// check $clob is of type 'OCI-Lob' here

It's pointless to check it because oci_new_descriptor() can return only two things - NULL and OCI-Lob class instance.
 [2011-11-09 23:50 UTC] sixd@php.net
-Package: oci8 +Package: OCI8 related
 [2013-01-03 22:53 UTC] r dot ejem at seznam dot cz
I don't see type-checking pointless especially in PHP which has poor to no compile-time type-checking.
I think this bug should be fixed in future version. Invalid class name of a built-in class is, I think, a terrible mistake, which has to be definitely fixed.
 [2015-10-12 18:44 UTC] ashnazg@php.net
"if (is_a($clob, 'OCI-LOB')) {" is working fine for me (PHP 5.5.24)... should this bug be closed?
 [2016-10-28 03:41 UTC] m at ahungry dot com
When using PHP7, how can this class be type hinted?

I think this class should be renamed to OCI_Lob instead of OCI-Lob to maintain standard naming conventions.
 [2019-02-17 00:14 UTC] tandre@php.net
I'd be in favor of doing the following:

1. Add OCI_Lob as an internal class alias of OCI-Lob in PHP 7.4 and documenting that
2. Dropping the original OCI-Lob name in PHP 8.0
3. Forbidding internal extensions from registering class names that would be impossible for PHP code to do, in PHP 8.0 (e.g. hyphens, starting with numbers, etc)

It seems doable - zend_register_class_alias("_ZendTestClassAlias", zend_test_class);  seems to do that in ext/zend_test/test.c

Same for OCI-Collection/OCI_Collection, etc.

There are several reasons for making this change:

1. The classes from OCI can't be type hinted in PHP programs for param/return types in the signature, as mentioned earlier
2. This makes uses of those class difficult to statically analyze, and will make any tools performing sanity checks of class names from Reflection fail. See https://github.com/phan/phan/issues/2222 and https://github.com/phan/PHPSignatures/pull/3#discussion_r246262546
3. The workarounds used by static analyzers and IDEs may mislead users into thinking that `$x instanceof OCI_Collection` will work properly, making bugs more likely
 [2019-02-21 11:38 UTC] nikic@php.net
@tandre: Sounds good to me. I'd suggest renaming the class to OCI_Lob and making OCI-Lob the alias though, to make everything use the new class name (while still being compatible with OCI-Lob, if someone goes out of the way to use it).
 [2020-05-25 20:46 UTC] bugs dot php dot net_nospam at adviesenzo dot nl
As PHP 7.4 has come and gone and we're now at PHP 8, I believe ow would be a great time to address this at long last.

My vote goes to renaming both the `OCI-Collection` and `OCI-Lob` classes to `OCI_Collection` and `OCI_Lob` respectively and adding an alias for each with the old name.


Also see: https://bugs.php.net/bug.php?id=79625
 [2020-10-27 10:11 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-10-27 10:11 UTC] cmb@php.net
These classes are renamed to OCILob and OCICollection as of PHP
8.0.0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC