|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 13:00:02 2025 UTC |
"if (is_a($clob, 'OCI-LOB')) {" is working fine for me (PHP 5.5.24)... should this bug be closed?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