When calling taxonomy_term.selectNodes from flash using amfserver no nodes are returned. This seems to be a result of $uri = services_resource_uri(array('node', $nid)) not returning anything.

Will commit a patch today with a suggested solution.

Comments

robin van emden’s picture

StatusFileSize
new1.38 KB
robin van emden’s picture

Status: Active » Needs review
robin van emden’s picture

StatusFileSize
new1.26 KB

Small formatting fix.

kylebrowning’s picture

Why are you not using services_resource_uri?

EDIT: woops should have read the first post.

kylebrowning’s picture

Project: Services » amfserver
Version: 7.x-3.x-dev » 7.x-3.0-rc1

This is a bug in amfserver i believe, it works for me, AND the tests pass for me. I tested in php 5.2 and 5.3
https://skitch.com/kylebrowning/ffn7f/untitled

robin van emden’s picture

Thanks. I will continue my investigation into this issue.

rolf vreijdenberger’s picture

Hi Robin,
nice to see you involved again on the drupal side of things. Do you have an update on this issue?

robin van emden’s picture

Project: amfserver » Services
Version: 7.x-3.0-rc1 » 7.x-3.x-dev

Hi Rolf,

I was away for a few days, finally found the time to dig a little deeper.

I am still unconvinced this is a definite bug in Amfserver. If so, the same bug can be found in the XMLRPC server.

The problem is the need for the services_resource_uri function to return an uri , if the taxonomy_service_select_nodes function is to return anything.

The services_resource_uri function is found in services.runtime.inc, where it looks for a uri formatter through services_get_server_info, which otherwise returns null:

  ...
  function services_resource_uri($path) {
    $formatter = services_get_server_info('resource_uri_formatter');
    if ($formatter) {
      return call_user_func($formatter, $path);
    }
    return NULL; 
  }
  ...

This works fine IF the server (REST, XMLRPC, AMF) has defined this server value first, for example in RESTServer.inc:

  ...
  services_set_server_info('resource_uri_formatter', array(&$this, 'uri_formatter'));
  ...
  /**
   * Formats a resource uri
   *
   * @param array $path
   *  An array of strings containing the component parts of the path to the resource.
   * @return string
   *  Returns the formatted resource uri
   */
  public function uri_formatter($path) {
    return url($this->endpoint_path . '/' . join($path, '/'), array(
      'absolute' => TRUE,
    ));
  }
  ...

The patch circumvented the services_resource_uri function, which made sure the function returned a value, instead of null.

So either:

  • XMLRPC, amfserver and any other server are required to set the resource_uri_formatter
  • services_resource_uri is circumvented (as per patch)
  • or services_resource_uri needs to fall back to a default value/function if not defined by the server

There has been some discussion on this subject here: #1086526: Missing url path / url alias

Since the choices mentioned have broader implications than amfserver, I think it is prudent I reassign the this issue to the Services module again.

robin van emden’s picture

Assigned: robin van emden » Unassigned
kylebrowning’s picture

Ok, is this also broken in drupal 6?

robin van emden’s picture

Found some time to test this for XMLRPC server in D6, and the answer is no, this is not broken in the same way in D6.

In D6, taxonomy_term.selectNodes does not make use of services_resource_uri - it can be found in other resources (file, comment, node, user), but I have not had time to test these service in XMLRPC.

I did encounter a problem for taxonomy_term.selectNodes when using XMLRPC, a quick fix was changing

function taxonomy_service_select_nodes($tids, $fields , $operator , $depth, $pager , $order) {               

for

function taxonomy_service_select_nodes($tids=array(), $fields=array() , $operator , $depth, $pager , $order='n.sticky DESC, n.created DESC') {               

but that is a different issue.

kylebrowning’s picture

I see the issue, servers not required to have a resource uri formatter, however you probably should so that you can take advantage of calling that URI to load a specific entity.

Im running a test on this fix, and if it works ill fix it across the board and close this ticket.

kylebrowning’s picture

Status: Needs review » Fixed

Ok it worked, this has been fixed in dev.

My solution was much simpler, move the node_load outside of the resource uri_formatter.

kylebrowning’s picture

Status: Fixed » Closed (fixed)