node.get method should not use the node_load function to get the node object
| Project: | Services |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | snelson |
| Status: | closed |
Jump to:
Hi,
If the intention of the node.get method is to present a copy of a node, as an object, which can be presented to another Drupal installation over web services (which is how we are using it, and I guess is a popular use case) then it needs to change the way it works slightly. The node_load function runs the node body through the HTML filter, which means the node body presented by the method is not truly what is stored in the database table - it's not a perfect copy of the node any more. Ideally the node object should be passed as it is stored in the database. For a detailed example of why this causes a problem, please read this blog post:
http://www.drupaler.co.uk/blog/warning-node-module-and-teaser-weirdness/123
That said, it is useful to have things like the CCK data, which would not be available if you were not using node_load function, so perhaps node_load is still the way, but the node body should be replaced with a direct call to the revisions table to fetch the unformatted node body?
Anyway, the point is that the way node.get currently loads and presents nodes can cause an issue, as detailed in the above post. Thoughts welcome. =)

#1
To me, that's not the intention of services. Web services provide an abstraction layer between the consumer application and the website (be it Drupal or something else) itself. To accomplish this, I'm writing proxy methods that convert typical Drupal objects - with a lot of specific CCK data structures - into a simplified struct.
I just wanted to point out this use case.
So, I'd opt for a flexible solution that serves both use cases, being 'Drupal to Drupal' and 'Drupal to other'.
But I don't have a proposition (right now).. somebody else?
#2
I'd agree completely. You're right - there are use cases where the current behaviour would be desired. A true Drupal to Drupal node service will probably require a bit of thought. Perhaps node.get should stay as it is and a new node.getRaw method (or something like that) be created for Drupal to Drupal node object duplication?
#3
Actually, node_load is pretty much raw data. services_node_load() wraps node_load in node.get requests which runs the body through the filter. Removing this behavior and perhaps adding a node.view method would likely solve the problem. But, we'll have to make sure this is well documented in the next release for existing apps that may be depending on formatted body.
Greg, I just read your blog, post, you probably wanna kill me now :)
I'm just gonna go ahead and fix this.
Scott
#4
Committed to D5 and D6.
Removed filter on body and teaser in node.load and node.get, then added a new service called node.view to be able to load formatted node data.
#5
LOL, thanks for fixing. No death required. ;-)
#6
it might of been a better idea to make a new method to get the unformatted data, as lots of applications out there are currently counting on node.load / node.get to return formatted data and the ones that need unformatted data are already used to getting formatted data with node.load / node.get so they probably already have made a custom way around this
#7
Automatically closed -- issue fixed for 2 weeks with no activity.