I wanted to start a separate thread for this issue because I think it was reported on another thread that sorta had something to do with it but anyhow..

With PHP 5.3 and above something changed in call_user_fun_array thats throwing off the services module in instances such as system.connect, system.getServices etc.

warning: call_user_func_array() expects parameter 2 to be array, null given in /var/www/sites/all/modules/services/services.module on line 434

and I think same error on 450...

Server, Ubuntu.. running Apache 2 with PHP Version 5.3.2-1ubuntu4.2

CommentFileSizeAuthor
#6 services-809226.patch652 bytesgilgabar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gateway69’s picture

any updates to this, im in the process of writing service modules and seeing this quite often now with a very basic test.. its also returning access denied...

codekarate’s picture

I am also in the process of writing services modules and am seeing this same error.

Server OS: Ubuntu
Webserver: Nginx
PHP: 5.3

codekarate’s picture

I took a look at the code and was able to get around this error by making sure I passed some type of argument ('#args') in hook_service. It looks like the code expects you to have some type of argument declared, even if it is an optional argument.

I don't think it is the end solution but it is a good work around for me.

estenat’s picture

I verified the trouble is in call_user_func_array (function services_method_call inside services.module) when it assigns values to $access_arguments at row 423:
$access_arguments = $method['access arguments'];
because this assignement makes $access_arguments a simple string variable, instead of an array variable.
The following row:
$access_arguments = array($method['access arguments']);
load an effective array...

This solved my problem that raised installing services 6.x-2.1 over 6.x-2.0 (as I reported in issue 'Service does not work with Dash Media Player')

gilgabar’s picture

The problem doesn't appear to be in services_method_call() but in one of the functions that calls it. The second argument, $args, should be an array, but it is actually a NULL. That NULL is being passed from the function calling it. In this case it looks like only the admin testing interface is affected. I wasn't able to create any errors querying the xmlrpc server directly.

So the problem lies in services_admin_browse.inc. The calling function is services_admin_browse_test_submit(). The $args variable is populated by services_admin_browse_test_unserialize_args(), which is creating the NULL value. It looks like a simple uninitialized return variable. If there are no $values passed to the function then it will return the $return variable without actually assigning any value to it. The solution that works for me is to just initialize that $return variable as an empty array.

<?php

function services_admin_browse_test_unserialize_args($values, $formats) {
  $return = array();
  $method = services_method_get(arg(4));
  $noskip = FALSE;
  ...
?>
gilgabar’s picture

Status: Active » Needs review
FileSize
652 bytes

Here is a patch.

gdoteof’s picture

#6: services-809226.patch queued for re-testing.

jonathan_hunt’s picture

I found a similar issue in services_method_call() in services.module ~ line 445. For a method defined with no args, $args is NULL and call_user_func_array() dies. The following is a workaround:

  $args = (array)$args; // for PHP5.3
  $result = call_user_func_array($method['callback'], $args);
gilgabar’s picture

That should also be resolved by the patch in #6. It's the same variable.

marcingy’s picture

Status: Needs review » Fixed

Ah this appears as duplicate of the commit I made earlier, marking as fixed given that, this fix is in 6-x-2 head.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

EDDYL’s picture

This bug IS NOT fixed :
call_user_func_array() expects parameter 2 to be array, string given in C:\Program Files\EasyPHP-5.3.6.0\www\drupal_preprod\modules\services\services.module on line 446.

Unable to deploy content-types

marcingy’s picture

6.2 is no longer supported so this issue will not be fixed anyway. And the usage of capitals is a sure way to ensure that is the case.

babymission’s picture

I could not find this string in my Service module (Services 6.x-0.15). Instead I can only find the following:-

$access_arguments = isset($method['#access arguments']) ? $method['#access arguments'] : $args;
// Call default or custom access callback
if (call_user_func_array($method['#access callback'], $access_arguments) != TRUE) {
return services_error(t('Access denied.'));

How should I modify this to make it work? Thanks.

qasimzee’s picture

I changed line 435 to $access_arguments[] = $method['access arguments']; and the error is fixed

freebug’s picture

I was able to solve my issue be putting the following code at the top of the "services_method_call" function, in the services.module file:

if(is_null($args)){
	$args = array();
}

Also I made changes to the includes/xmlrpcs.inc (line no 150 in my case). Added check for 'null' also:

if ($args && (!is_array($args) || is_null($args))) {

This might not be necessary in all the cases.