Error thrown:

Warning: strcmp() expects parameter 1 to be string, array given in _system_sort_requirements() (line 1124 of C:\Users\Sylvain\Travail\Duedil\html\modules\system\system.module).
Warning: usort() [function.usort]: Array was modified by the user comparison function in system_status() (line 1704 of C:\Users\Sylvain\Travail\Duedil\html\modules\system\system.admin.inc).

Step to reproduce:

- Install simpletest module
- Install fbconnect module
- Go to admin normal page. Error is thrown

Debugger:

On the debugger, this is caused because on those modules, they both define $requirements['curl'] variable.

simpletest.install (line 146 to 153) 6.x-2.x-dev:

$requirements['curl'] = array(
    'title' => $t('cURL'),
    'value' => $has_curl ? $t('Enabled') : $t('Not found'),
  );
  if (!$has_curl) {
    $requirements['curl']['severity'] = REQUIREMENT_ERROR;
    $requirements['curl']['description'] = $t('Simpletest could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/en/curl.setup.php'));
  }

fbconnect.install (line 12 to 21) 6.x-2.0-alpha1:

if (function_exists('curl_init')) {
      $curl_info = curl_version();
      $requirements['curl']['value'] = $curl_info['version'];
      $requirements['curl']['severity'] = REQUIREMENT_OK;
    }
    else {
      $requirements['curl']['value'] = t('Not installed');
      $requirements['curl']['severity'] = REQUIREMENT_ERROR;
      $requirements['curl']['description'] = t('The cURL library is not installed. Please check the <a href="@url">PHP cURL documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/curl.setup.php'));
    }

Comments

rgdonaldson’s picture

I downloaded bitcache ("6.x-1.0-beta2") and this and some other errors related to bitcache started to occur.

Sylvain Lecoy’s picture

This is probably because requirements interfere with other modules.

It stacks into an array if the $key for requirement are defined in several modules. In my case 'curl' was defined two times, that's why the sorting function couldn't sort it (expected parameter to be string)

Sylvain Lecoy’s picture

Status: Active » Needs work

Is that need work maybe ?

abaddon’s picture

Status: Needs work » Active

i can confirm this too, and it only happens after i moved the site to a newer version of php

abaddon’s picture

Version: 6.19 » 6.20

found the culprit too, seems that there are similar issues posted all over the place http://drupal.org/node/1122694 http://drupal.org/node/929010 http://drupal.org/node/999680

this is because some module defines a $requirements array member that has already been defined, in my case it was the piwik module defining $requirements['http requests'] = array(.. but only in some cases (when the http request failed - hence why i though it was because of moving to a new system)

the fix is simple, put the definition in the module's name space like so: $requirements['piwik http requests'] = array(.. AND post an issue on that module's issue queue :-)

should this be fixed in drupal? or close the issue? there should be some protection, but then again, theres a lot of places where contrib can break a site and theres no fix for good judgment

Sylvain Lecoy’s picture

I didn't test in drupal 7, maybe we should fix here first (or in d8-dev) then backport. Any feedback from drupal comitters please ?

acbramley’s picture

This issue persists in Drupal 7 (same issue with Piwik duplicating the System module's tests). Not too sure how it's caused as it would seem to me if 2 modules delcared a requirement with the same key then one would override the other, not merge the values from both. Especially considering Drupal can't handle arrays.

It's hard to decide whether it should be fixed in core or in the contrib modules. On one hand, the developer should provide unique keys (just like when defining functions etc), but also it seems that core should be able to handle the array without throwing it's toys. #1271780: $requirements['http requests'] is already set, piwik creates it anew is the issue that contains a patch for the Piwik module that fixes this issue.

Sylvain Lecoy’s picture

I think the best practises are to put requirements with the module namespace.

That is:

$requirements['curl'] is wrong and can conflict with other modules.

$requirements['mymodule']['curl'] is a best practise.

Sylvain Lecoy’s picture

Version: 6.20 » 7.x-dev

Tagging at 7.x-dev.

Either need doc for best practises, either need to be fixed to support same requirement on the same key.

socialnicheguru’s picture

In my Drupal 7.10 install all the following modules have $requirements['curl'] :
constant_contact
linkechecker
signup
simpletest
sms_twilio
wysiwyg

Is this something that can be turned off by disabling notices? Does it do any real harm except slow down server performance?

Edit:
manually changing the requirements in the install file of each of the modules as #5 outlined got rid of the error

ParisLiakos’s picture

Version: 7.x-dev » 8.x-dev

This is present in d8 as well and is exposed by drupal core alone, when you enable both simpletest and aggregator, since both of them actually require curl
closed #1867878: Warning: strcmp() expects parameter 2 to be string, array given in _system_sort_requirements() as duplicate

ParisLiakos’s picture

Title: multiple requirements from different modules cause an error in sorting arrays in system.module line 1124. » Same requirements from different modules causes warnings in _system_sort_requirements()
Status: Active » Needs review
StatusFileSize
new820 bytes

here is a patch that gets rid of warnings

ParisLiakos’s picture

Note: we could also replace array_merge_recursive in module_invoke_all with drupal_array_merge_deep but i am pretty sure we dont want to do that, cause there might be code depending on this functionality

ParisLiakos’s picture

xurizaemon’s picture

trbirdsall’s picture

@ParisLiakos: Thanks for #12 patch. Used to see a lot of these in the admin pages:

Warning: strcasecmp() expects parameter 2 to be string, array given in _system_sort_requirements() (line 2818 of /home/trbirdsall/public_html/Route191.com/modules/system/system.module).
Warning: strcasecmp() expects parameter 2 to be string, array given in _system_sort_requirements() (line 2818 of /home/trbirdsall/public_html/Route191.com/modules/system/system.module).
Warning: strcasecmp() expects parameter 1 to be string, array given in _system_sort_requirements() (line 2818 of /home/trbirdsall/public_html/Route191.com/modules/system/system.module).
Warning: strcasecmp() expects parameter 2 to be string, array given in _system_sort_requirements() (line 2818 of /home/trbirdsall/public_html/Route191.com/modules/system/system.module).
Warning: usort(): Array was modified by the user comparison function in system_status() (line 2335 of /home/trbirdsall/public_html/Route191.com/modules/system/system.admin.inc).

Also there was a Warning message on the Status page that was simply labeled "Array, Array".

Fixed up the same issue running jQuery = 1.10, with a clean install of Drupal 7.42, (modules were installed in this order: date, date API, date popup, jQuery update, variable, x-autoload, services, Chaos tools, REST server, entity API, views bulk operations, views megarow, rooms availability, rooms unit, rooms, rooms UI, BAT tools API, BAT unit, BAT event, BAT event UI, BAT fullcalendar).

deanflory’s picture

My errors turned out to be due to an error in the LinkedIn module:
https://www.drupal.org/node/1711604

Changing [curl] to [curl_linkedin] in the .install file worked.

deanflory’s picture

Thanks me, I helped myself out again after updating linkedin. :)

hassebasse’s picture

simpleads seem to have been my problem.

All the best

Hans