After updating to the latest dev version this morning I am getting the warnings below. I think I was getting these earlier, but I either patched or they went away on their own. Any idea how to fix?

When I trying to debug (e.g. dpm($resource, '_services_process_resource $resource');) almost all results are arrays, except I am seeing two places (one for each _services_process_resource and _services_apply_endpoint) that show a value of 3002 (e.g. _services_apply_endpoint $resource => 3002 from the dpm output). Not sure where that is coming from. I only have two custom resources enabled and they only retrieve 'methods' -- resources are pasted below the warning output.

    Warning: Cannot use a scalar value as an array in _services_process_resource() (line 152 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Cannot use a scalar value as an array in _services_apply_endpoint() (line 101 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Invalid argument supplied for foreach() in services_edit_form_endpoint_resources() (line 286 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/plugins/export_ui/services_ctools_export_ui.class.php).
function pfcc_lesson_services_resources() {
  $node_resource = array(
    'lesson' => array(
      'retrieve' => array(
        'callback' => '_pfcc_services_node_resource_retrieve',
        'args' => array(
          array(
            'name' => 'nid',
            'optional' => FALSE,
            'source' => array('path' => 0),
            'type' => 'int',
            'description' => 'The nid of the node to get',
          ),
        ),
        'access callback' => '_node_resource_access',
        'access callback file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/node_resource'),
        'access arguments' => array('view'),
        'access arguments append' => TRUE,
      ),
    ),
  );
  return $node_resource;
}
function pfcc_standalone_article_services_resources() {
  $node_resource = array(
    'standalone_article' => array(
      'retrieve' => array(
        //'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/node_resource'),
        'callback' => '_pfcc_services_node_resource_retrieve',
        'args' => array(
          array(
            'name' => 'nid',
            'optional' => FALSE,
            'source' => array('path' => 0),
            'type' => 'int',
            'description' => 'The nid of the node to get',
          ),
        ),
        'access callback' => '_node_resource_access',
        'access callback file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/node_resource'),
        'access arguments' => array('view'),
        'access arguments append' => TRUE,
      ),
    ),
  );
  return $node_resource;
}

Comments

ygerasimov’s picture

Could you please resave your endpoint settings and advise whether this problem still persist. Also please advise when do you have these warnings? Is it on save of the endpoint or the call?

RobKoberg’s picture

I am not getting the error on a clean install, so it must be something on my end...

It occurs on view of the 'Edit Resources' for an endpoint, e.g.: /admin/structure/services/list/base_services/resources

On save of that page, I get several more warnings:

    Warning: Cannot use a scalar value as an array in _services_process_resource() (line 150 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Cannot use a scalar value as an array in _services_apply_endpoint() (line 100 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Invalid argument supplied for foreach() in services_edit_form_endpoint_resources() (line 286 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/plugins/export_ui/services_ctools_export_ui.class.php).
    Warning: Cannot use a scalar value as an array in _services_process_resource() (line 150 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Cannot use a scalar value as an array in _services_apply_endpoint() (line 100 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Cannot use a scalar value as an array in _services_process_resource() (line 150 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Cannot use a scalar value as an array in _services_apply_endpoint() (line 100 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/services.resource_build.inc).
    Warning: Invalid argument supplied for foreach() in services_edit_form_endpoint_resources() (line 286 of /Users/rkoberg/Sites/pfcc/www/sites/all/modules/services/plugins/export_ui/services_ctools_export_ui.class.php).
kylebrowning’s picture

Do you mind exporting your endpoint so I can import it?

RobKoberg’s picture

Here you go:

$endpoint = new stdClass();
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'base_services';
$endpoint->server = 'rest_server';
$endpoint->path = 'services';
$endpoint->authentication = array(
  'services' => 'services',
);
$endpoint->server_settings = array(
  'rest_server' => array(
    'formatters' => array(
      'json' => TRUE,
      'xml' => TRUE,
      'bencode' => FALSE,
      'jsonp' => FALSE,
      'php' => FALSE,
      'rss' => FALSE,
      'yaml' => FALSE,
    ),
    'parsers' => array(
      'application/json' => TRUE,
      'application/x-www-form-urlencoded' => TRUE,
      'application/vnd.php.serialized' => FALSE,
      'application/x-yaml' => FALSE,
      'multipart/form-data' => FALSE,
    ),
  ),
);
$endpoint->resources = array(
  'lesson' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'standalone_article' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'user' => array(
    'actions' => array(
      'login' => array(
        'enabled' => 1,
      ),
      'logout' => array(
        'enabled' => 1,
      ),
    ),
  ),
);
$endpoint->debug = 1;
kylebrowning’s picture

that looks fine, what about standalone article and lesson definitions. Can I see those?

zengenuity’s picture

I got this same message when I had the UUID Services module enabled. Disabling the module fixed the issue. I'm not sure if that's the same problem as the original poster had, but posting it for others.

kylebrowning’s picture

Status: Active » Closed (cannot reproduce)

I still cannot reproduce this. Can someone provide some steps to do so?