Solution for warning in Drupal - call_user_func_array() expects parameter 2 to be array, string given in sites/all/modules/contrib/views/views.module

| | 1 min read

We recently saw this error on a Drupal 6 site that had not been updated for quite a while."warning: call_user_func_array() expects parameter 2 to be array, string given in sites/all/modules/contrib/views/views.module" means what it says. call_user_func_array expects the second parameter to be an array whereas a string was given instead. You can troubleshoot problems like this by writing a bit of debug code before the line where the error is reported.

In this case you would want to write a condition that checks whether the second parameter that is passed to the call_user_func_array is indeed an array and if not, use debug_backtrace to print the backtrace for call and see where the request originated from. Since debug_backtrace prints out the arguments that are passed to these function calls as well you will be able to trace and find the location where the error crept into the system.

In our case the error originated from an incorrect implementation of the get_access_callback method in class views_plugin_access_perm class present in file inside plugins folder inside views. The callback was called with the second argument as a permission string instead of as a single valued array. The solution to the problem was to first patch the file to change the second argument to a single valued array with the single permission as the parameter.

The above may not be the problem in your case but you can follow a similar approach to find the solution to your problem.