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
Comment #1
rgdonaldson commentedI downloaded bitcache ("6.x-1.0-beta2") and this and some other errors related to bitcache started to occur.
Comment #2
Sylvain Lecoy commentedThis 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)
Comment #3
Sylvain Lecoy commentedIs that need work maybe ?
Comment #4
abaddon commentedi can confirm this too, and it only happens after i moved the site to a newer version of php
Comment #5
abaddon commentedfound 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
Comment #6
Sylvain Lecoy commentedI didn't test in drupal 7, maybe we should fix here first (or in d8-dev) then backport. Any feedback from drupal comitters please ?
Comment #7
acbramley commentedThis 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.
Comment #8
Sylvain Lecoy commentedI 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.
Comment #9
Sylvain Lecoy commentedTagging at 7.x-dev.
Either need doc for best practises, either need to be fixed to support same requirement on the same key.
Comment #10
socialnicheguru commentedIn 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
Comment #11
ParisLiakos commentedThis 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
Comment #12
ParisLiakos commentedhere is a patch that gets rid of warnings
Comment #13
ParisLiakos commentedNote: 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
Comment #14
ParisLiakos commentedthis will be fixed once #1356170: Remove all uses of array_merge_recursive, or document why they are being used instead of NestedArray::mergeDeep() is in
Comment #15
xurizaemonTagging in several affected 7.x modules (fbconnect, linkedin integration, simpletest, fb_autopost) so that affected 7.x sites can use this issue to track their conflicts down.
Comment #16
trbirdsall commented@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).
Comment #17
deanflory commentedMy 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.
Comment #18
deanflory commentedThanks me, I helped myself out again after updating linkedin. :)
Comment #19
hassebasse commentedsimpleads seem to have been my problem.
All the best
Hans