Bug #70756 [NEW]: Choice elements aren't working as expected

From: Date: Wed, 21 Oct 2015 09:02:37 +0000
Subject: Bug #70756 [NEW]: Choice elements aren't working as expected
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196721@lists.php.net to get a copy of this message
From: php at xploseof dot com Operating system: CentOS PHP version: Irrelevant Package: SOAP related Bug Type: Bug Bug description:Choice elements aren't working as expected Description: ------------ We're using a classmap, together with protected properties for each property that might be in the requests/responses. We're using the same classes for sending and receiving - an SDK as it were. Our class has getters and setters - important to note here that the setters will throw an error if you try setting both, so it's a direct replication of what the XML allows, in programming form (as opposed to markup). The issue comes about when there is a choice. There are two properties on the class, but the first of the XSD definition has no value (i.e. it is null). It therefore ignores the second, and doesn't put in the first. In these cases, I would expect it to work out "null" means it is not defined, and therefore look at the second option and so on. Test script: --------------- <xs:complexType name="Test"> <xs:choice> <xs:element name="Item2" type="xs:string"/> <xs:element name="Item1" type="xs:string"/> </xs:choice> </xs:complexType> class Test { protected $Item1; protected $Item2; public function get_item1() { return $this->Item1; } public function get_item2() { return $this->Item2; } public function set_item1($value) { if($this->Item2) { throw new \Exception('Can only define Item1 or Item2'); } $this->Item1 = $value; } public function set_item2() { if($this->Item1) { throw new \Exception('Can only define Item1 or Item2'); } $this->Item2 = $value; } } -- Edit bug report at https://bugs.php.net/bug.php?id=70756&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70756&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70756&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70756&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70756&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70756&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70756&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70756&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70756&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70756&r=support Expected behavior: https://bugs.php.net/fix.php?id=70756&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70756&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70756&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70756&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70756&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70756&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70756&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70756&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70756&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70756&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70756&r=mysqlcfg

« previous php.bugs (#196721) next »