|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58034 alphabetical order of type names impacts
Submitted: 2008-02-08 08:34 UTC Modified: 2017-01-10 08:10 UTC
From: oliver dot hofer at itp-solutions dot ch Assigned:
Status: Suspended Package: SCA_SDO (PECL)
PHP Version: 5.2.5 OS: Win-XP, Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
45 - 31 = ?
Subscribe to this entry?

 [2008-02-08 08:34 UTC] oliver dot hofer at itp-solutions dot ch
If the name of the super-type is alphabetically (sorted)  AFTER the type name of the derived (extension, restriction) type in the schema, assigning a value to a property of that type fails. 

The schema defines a upl-object which has a creationType property. The creationType-property is of the type lovCreationTypeType which is a restriction of lovType which is a restriction of xs:int. In my (original) example, the type name is lovCreationTypeType which is alphabetically sorted BEFORE lovType where it is derived from. 

Example code and schemas are available here:

In PHP-Code, the property can not be set using 
$upl->creationType = 1234 after having created the upl-object. 

After renaming the type lovCreationTypeType to be lovZZCreationType, assigning a value works. Reproduction is possible on WinXP SP2, Apache 2.2.6, PHP 5.2.5 and Linux Fedora Core 6, Apache 2.2.6, PHP 5.2.5

Reproduce code:
$xmldas = SDO_DAS_XML::create();

$document = $xmldas->createDocument('', 'upl');
$upl = $document->getRootDataObject();
$upl->creationType = 1234;

header('Content-Type: text/xml');
echo $xmldas->saveString($document);

$xmldas = SDO_DAS_XML::create();

$document = $xmldas->createDocument('', 'upl');
$upl = $document->getRootDataObject();
$upl->creationType = 1234;

Expected result:
The code above can be used to reproduce the bug using 2 different schemas (sdo_working.xsd, sdo_test.xsd) The first test uses sdo_working.xsd which defines the type lovZZCreationTypeType (derived from lovType) to assign a value to $upl->creationType. The resulting XML is printed out. 

The second test uses sdo_test.xsd where the definition of the creationType element is of the type lovCreationTypeType. Teh result is a SDO_UnsupportedOperationException which is catched.

The script may be run in a browser, the result (Source code) is shown below.

Actual result:
<?xml version="1.0" encoding="UTF-8"?>
<tns:upl xmlns:tns="" xmlns:xsi=""><tns:creationType>1234</tns:creationType></tns:upl>
<br />
<b>Fatal error</b>:  Uncaught exception 'SDO_UnsupportedOperationException' with message 'main(): cannot cast integer to SDO_DataObject for 'creationType'' in D:\workspaces\ftxml\test\sdo_test.php:21
Stack trace:
#0 D:\workspaces\ftxml\test\sdo_test.php(21): unknown()
#1 {main}
  thrown in <b>D:\workspaces\ftxml\test\sdo_test.php</b> on line <b>21</b><br />


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-11 04:20 UTC] oliver dot hofer at itp-solutions dot ch
Forgot to mention: SDO version 1.2.3
 [2008-02-14 07:26 UTC] oliver dot hofer at itp-solutions dot ch
Created a php-Test for it:

SDO test for alphabetical type order bug
if (!extension_loaded("sdo"))
    echo "skip sdo not loaded";

$xsd = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace=""

  <xs:simpleType name="lovType">
    <xs:restriction base="xs:int">
      <xs:totalDigits value="3"/>

  <xs:simpleType name="lovCreationTypeType">
    <xs:restriction base="lovType"/>

  <xs:simpleType name="lovZZCreationTypeType">
    <xs:restriction base="lovType"/>

  <xs:element name="creationType" type="lovCreationTypeType">

  <xs:element name="creationTypeZZ" type="lovZZCreationTypeType">

  <xs:complexType name="batchRequestType">
      <xs:element ref="creationType"/>
      <xs:element ref="creationTypeZZ"/>

  <xs:element name="upl" type="batchRequestType">

$schema_file = tempnam(NULL, 'xsd');
file_put_contents($schema_file, $xsd);

$xmldas = SDO_DAS_XML::create($schema_file);

$document = $xmldas->createDocument('', 'upl');
$upl = $document->getRootDataObject();

$upl->creationTypeZZ = 1234;
$upl->creationType = 1234;

echo ($upl->creationTypeZZ == 1234) ."\n";
echo ($upl->creationType == 1234);
 [2008-02-15 10:01 UTC]
I just tried this phpt test and get "Uncaught exception 'SDO_UnsupportedOperationException' with message 'main(): cannot cast integer to SDO_DataObject for 'creationType'" when I run it. I haven't dug into it to understand why yet.
 [2008-02-18 05:10 UTC] oliver dot hofer at itp-solutions dot ch
I think, it must not throw an exception. The two properties (creationType and creationTypeZZ) are both derived from lovType which is a (restricted) integer. Therefore it must be possible to assign an integer to both of them. 
I just noticed, that lovType is restricted to 3 digits - perhaps the test must be adjusted to pass.
 [2017-01-10 08:10 UTC]
-Status: Open +Status: Suspended
 [2017-01-10 08:10 UTC]
Suspending this report as the extension have not had a release for almost 9 years.  Please revive this if the extension once again shows life
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 11:01:27 2023 UTC