I have a content type that has a field called "map" that refers to a "GMaps Address and Point" field (called "field_map"). Attempting to save nodes using the node.save service (in this case through a Python XMLRPC client API that uses sessions and keys for authentication) causes an error to come through (I had to look closely at the response within the depths of the XMLRPC lib):
Fatal error: Cannot use object of type stdClass as array in /srv/www/mysite.com/public_html/sites/all/modules/gmaps/includes/gmaps.point-element.inc on line 374.
This code appears to execute, yet the field is not a required field nor have I supplied any specific values for it. The line inside _gmaps_point_set_return_value checks for the existence of a "privacy" field (but does not use the array_key_exists function to check for the presence of the data element).
If I remove the "GMaps Address and Point" field from my content type and attempt to use node.save again, everything works fine.
Questions:
1. Why would this code execute if there are no values for the field supplied in the node supplied to node.save and the field is not a required field?
2. Should the function use the array_key_exists function to check to see if the privacy field has been supplied? If I patch the code to include this check, I get the same error reported at the end of the function.
3. Has anyone been successful using node.save to create nodes that have GMaps Tools fields, and if so could you provide a sample?
Comments
Comment #1
myktra commentedAdditional testing confirms that this problem, as I might have expected, does not occur if the field is a "GMaps Address" field. Only the "point" feature associated with the "GMaps Address and Point" field appears to cause problems with saving nodes via the node.save service.
Also, there do not appear to be any configuration-related changes one can make to the "GMaps Address and Point" field (such as disabling the geocoder or turning off boundaries) to work around the issue, but I did not test this aspect exhaustively.
Comment #2
xmarket commentedThis is a variable type problem.
In regular context, FAPI always passes arrays for validation, but you (or the service module) pass an object, thus the code "$value['privacy']" fails on a php level. You must pass the value as an array not as an object.
Anyway, I'll change the code to skip the function _gmaps_point_set_return_value() on empty fields, and to use array_key_exists() on privacy checking.
Comment #3
myktra commentedThanks for the note, xmarket. Sounds good, looking forward to the patch/commit.
Fantastic module by the way! Will definitely share my success story with you and the Drupal community once my application is finished.
Comment #4
xmarket commentedComment #5
romanciuc commentedsame problem. I can't use the node_save on "GMaps Address and Point"
this is the code that fails to wrote the address and point (the code is creating the node but the address and point is missing)
Please let me know... i have two days to decide after that i will be forced to use the location module (manner of time) that is something that i don't want (becouse i like so much this module)
thanks an great job
mihai
Comment #6
lupus78 commentedThis causes the node_import module to fail with the GMaps Address and Point field type.
Comment #7
moun40 commentedSame problem as romanciuc, why node_save() doesn't work with "GMaps Address and Point". Working with point, with adress but not both. The node is saved but no adress in it.