Closed (cannot reproduce)
Project:
amfserver
Version:
7.x-3.0-rc1
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
15 Mar 2011 at 20:26 UTC
Updated:
11 May 2012 at 08:17 UTC
Jump to comment: Most recent file
Comments
Comment #1
ygerasimov commentedhere is patch to fix this issue
Comment #2
kylebrowning commentedComment #3
itarato commentedHi Guys,
I have the same problem but for a different reason. I'm using the node resource with Flex through amfserver ( http://drupal.org/project/amfserver ). The problem is that the node ID is a float - and I think it's because it's not integer when sending from Flex. But in Actionscript (3) it's just impossible to force it to be integer. It's always Numeric, even when defined as "var foo:int = 1;".
Can the node resource convert it to int when sending to node_load?
Thanks.
Comment #4
itarato commentedHere you are a patch I made and solve the problem. Please check it and let me know if it's not a good workaround. Thanks!
Comment #5
marcingy commentedThis code should not be in services core, can't this be dealt with the amfserver. Moving projects
Comment #6
marcingy commentedNot an action script programmer but it appears you can cast in action script http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d....
Comment #7
itarato commentedUnfortunately, I don't think it matters. I do a lot of Actionscript and it was strange to me also that even if your variable is strict integer it will be sent as Number, which is a float on the PHP side. I was checking the Zend AMF server classes and seems we hardly can do anything with it. When the Zend AMF server reads the request it will be float anyway. We won't know in the Amfserver, neither in Services module if the original variable was integer or float. So I still believe it should be converted in Services and in the proper resource functions.
Do you have other ideas?
Comment #8
rolf vreijdenberger commentedHey iterato,
is it sent as a number from flex/flash to php even it it's an int? in other words, is it a problem from drupal to flash/flex, vice versa or both?
when are you getting an error and what does it look like?
I'm abroad and not able to test, so info would be appreciated.
as far as I understand from the info above, this should be fixed (if it can be) in services.
and, looking at the patch, I can just load a node no problem if I use the dpdk actionscript framework. So again, I'm wondering where the error appears :)
Comment #9
marcingy commentedService has never cast nids so I don't believe it is a services issue, rather the issue is with actionscript and we have pleanty of flash based users. When I say it should be fixed in amfserver what I mean is that amfserver should do something similar to xmlrpc server which has a wraper callback and manipulates the data to an acceptable format for services. The above patch is a hack and not something that should be committed to services core.
And you do know when you need to convert as it is an explict arg that you are sending in so if you have a nid arg cast, tid, uid etc I assume will be the same.
Comment #10
itarato commentedSo the exact problem again:
I'm using NetConnection and Responder in Actionscript to send RPC calls. I'm passing int vars as arguments, but in the Flex debugger they all Number. So in the debugger you never can see int or uint type vars. And I think this is why the Zend AMF server gets them as float. It stays float untill node_load tries to load it:
node_load(FLOAT_NODE_ID) - and in node_load it becomes an array with the float value which cannot be array_flipped.
I assumed Services converts all variables at a lower level by the resource definition ( -> the node.retrieve service defines the nid param as int).
Anybody who has more experience in Actionscript - am I doing something wrong?
Comment #11
itarato commentedHi Rolf,
I'm trying out the DPDK AS framework (which is awesome btw :) ) and it has the same problem. Well, it's not your framework's issue, it's Actionscript itself.
I created a proxy, used node.retrieve with an integer, and in the node_resource.inc function (_node_resource_retrieve()) it arrived as double. And array_flip failed again.
Marc, what do you think?
Comment #12
marcingy commentedI have no knowledge of action script, so I can't help on that side. My view is given here http://drupal.org/node/1093762#comment-4436426, services should not be dealing with issues caused by specific servers, instead the servers should be responsible for formatting the data into appropriately before excuting the server call. I'm going to through this issue into irc to get some views hopefully from the other services people.
Comment #13
rolf vreijdenberger commentedHey guys
iterato: it happens in the default call to node.retrieve right?
This does not happen (array_flip error) in my flash example file included in the amfserver that I compile with flash cs5, can you give me a way to reproduce it?
example code
I'd rather not make exceptions on the amfserver side and check all incoming service calls to see if there are arguments I should cast, but it can easily be done.
marcingy: as far as the patch being a hack, this is more in the realm of architecture. You could argue a function should check it's own incoming parameters at least a bit to provide client protection and provide sensible defaults. It does not hurt actually. This makes sure clients of services don't need to write a lot of sanitizing code. And actually, this (sanitizing) is already done in places in services, so I don't see why it couldn't be implemented.
If you disagree with the above, you could then also argue that we don't need to check for the amount of arguments passed to a service method and have this be implemented by each server (or worse, each client of the specific server). Having a server enforce argument juggling breaks the idea of, and I quote "A standardized solution of integrating external applications with Drupal. Service callbacks may be used with multiple interfaces like XMLRPC, JSON, JSON-RPC, REST, SOAP, AMF, etc. This allows a Drupal site to provide web services via multiple interfaces while using the same callback code."
that said, it's no biggie for me, after I can do some research, it's easily implemented for the core service resources such as node etc.
iterato: if you could provide me with a screenshot, some code and reproduction steps,then I'll take a look
cheers guys
Comment #14
rolf vreijdenberger commented