joomla-projects / webservices

Webservices working group repository
GNU General Public License v2.0
16 stars 9 forks source link

JApiHalTransformXxxx::toExternal is being called twice for each field #14

Closed chrisdavenport closed 8 years ago

chrisdavenport commented 9 years ago

The toExternal transform is being called twice for each field. This doesn't give the correct result for some transforms such as JApiHalTransformState which transforms from a number to a non-numeric string.

Test 1: in JApiHalTransformString change

return (string) $definition;

to

return '[' . (string) $definition . ']';

then observe that the strings in the output are surrounded by '[[' and ']]' instead of just '[' and ']'.

Test 2: In site.contact.1.0.0.xml change the resource transform for 'published' from 'int' to 'state'. For a published contact item the expected output would be 'published', but you actually get 'unpublished'. In fact you get 'unpublished' regardless of the published state of the contact. What happens is that the first time it is called with a value of '1', it correctly transforms to 'published', but then it gets called again and 'published' gets transformed to 'unpublished'.

wilsonge commented 9 years ago

image

The backtrace of the two calls to the function