Both comment.load and comment.loadNodeComments currently return the raw column data from the database query in _comment_load(). Contrib modules can add information to the comment object inside hook_comment's "view" operation, however this hook isn't currently being called by either of the Services API functions.

Attached is a patch that modifies both Services API functions to pass each comment through hook_comment prior to returning it.

Comments

Status: Needs review » Needs work

The last submitted patch, comment_service-invoke-00.patch, failed testing.

smokris’s picture

Status: Needs work » Needs review
StatusFileSize
new833 bytes

(Fix relative directory in patch.)

skyredwang’s picture

Status: Needs review » Closed (works as designed)

hmmm. This is a good question. Comment services just pass the information to Drupal comment API. I noticed that comment_save() invoke contrib modules, but _comment_load() doesn't. see http://api.drupal.org/api/function/_comment_load/6

I would mark this as 'by design'

mradcliffe’s picture

Version: 6.x-2.2 » 6.x-3.x-dev
Category: bug » feature
Status: Closed (works as designed) » Needs work

Why would you mark this 'by design'? It seems to be more of a feature request to allow comments to be modified by contrib modules. Why would you limit the comment service to just what's in core? That doesn't make any sense to me.

I think the patch needs work, and should be bumped to 6.x-3.x-dev for development as a feature request.

For instance the old way returns an array of comments, but the patch just returns one comment. The patch should maintain the API. I'll try writing a patch for the next version.

kylebrowning’s picture

Assigned: Unassigned » kylebrowning
skyredwang’s picture

Status: Needs work » Closed (works as designed)

Services is only responsible for exposing existing core APIs in a standard way. Services module will not create "new" functions. If the Drupal core doesn't provide the comment functions that you need, you can write your own custom services. Or, you can file feature request to Drupal Core. This is marked as "by design".

silverwing’s picture

closing comments due to spam

ionut65’s picture

Issue summary: View changes

ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt

silverwing’s picture

Issue summary: View changes

Copy of the revision from March 6, 2012 - 00:07.