php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oliver dot hofer at itp-solutions dot ch
New email:
PHP Version: OS:

 

 [2008-02-08 08:34 UTC] oliver dot hofer at itp-solutions dot ch
Description:
------------
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:
http://ftxml-dev.itpnet.ch/test/test.zip
http://ftxml-dev.itpnet.ch/test/sdo_test.php
http://ftxml-dev.itpnet.ch/test/sdo_test.xsd
http://ftxml-dev.itpnet.ch/test/sdo_working.xsd

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:
---------------
<?php
$xmldas = SDO_DAS_XML::create();
$xmldas->addTypes('sdo_working.xsd');

$document = $xmldas->createDocument('http://example.com/model', 'upl');
$upl = $document->getRootDataObject();
$upl->creationType = 1234;

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

$xmldas = SDO_DAS_XML::create();
$xmldas->addTypes('sdo_test.xsd');

$document = $xmldas->createDocument('http://example.com/model', 'upl');
$upl = $document->getRootDataObject();
$upl->creationType = 1234;
unset($upl);
?>

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="http://example.com/model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><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 />

Patches

Pull Requests

History

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:

--TEST--
SDO test for alphabetical type order bug
--INI--
display_errors=off
--SKIPIF--
<?php
if (!extension_loaded("sdo"))
    echo "skip sdo not loaded";
?>
--FILE--
<?php

$xsd = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://example.com/model"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    version="1.3"
    xmlns="http://example.com/model"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

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

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

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

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

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

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

  <xs:element name="upl" type="batchRequestType">
  </xs:element>
</xs:schema>
EOF;

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

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

$document = $xmldas->createDocument('http://example.com/model', 'upl');
$upl = $document->getRootDataObject();

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

echo ($upl->creationTypeZZ == 1234) ."\n";
echo ($upl->creationType == 1234);
unset($upl);
?>
--EXPECT--
1
1
 [2008-02-15 10:01 UTC] mfp@php.net
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] kalle@php.net
-Status: Open +Status: Suspended
 [2017-01-10 08:10 UTC] kalle@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 06 06:01:29 2024 UTC