warning: strcmp() expects parameter 2 to be string, array given in H:\server\liveserverd\www\go\modules\system\system.module on line 1125.

Whenever you click Admin with Total Control enabled and you have php 5.3 u get this error:

warning: strcmp() expects parameter 2 to be string, array given in H:\server\liveserverd\www\go\modules\system\system.module on line 1125.
warning: strcmp() expects parameter 2 to be string, array given in H:\server\liveserverd\www\go\modules\system\system.module on line 1125.
warning: strcmp() expects parameter 2 to be string, array given in H:\server\liveserverd\www\go\modules\system\system.module on line 1125.

FIX:::: SYSTEM.MODULE LINES 1118-11133

/**
* Helper function to sort requirements.
*/
function _system_sort_requirements($a, $b) {
+ $a = array('weight','title');
+ $b = array('weight','title');
if (!isset($a['weight'])) {
if (!isset($b['weight'])) {
return strcmp($a['title'] ,$b['title']);
}
return -$b['weight'];
}
return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
}

/**

Comments

damien tournoud’s picture

Project: Drupal.org infrastructure » Drupal core
Version: » 6.x-dev
Component: Drupal.org module » base system
Category: bug » support
Status: Fixed » Closed (won't fix)

You probably have a misbehaving module in your installation, which implements hook_requirements() in a broken way.

livespots’s picture

Probably, either way... adding:

+ $a = array('weight','title');
+ $b = array('weight','title');

to system module fixed it.

binaryflo’s picture

livespots, your patch fixed stopped the error for me too.

php 5.3.3

lalit774’s picture

function _system_sort_requirements($a, $b) {
  if (!isset($a['weight'])) {
    if (!isset($b['weight']) && isset($a['title']) && isset($b['title'])) {
      return strcmp($a['title'], $b['title']);
    }
    if(isset($b['weight'])){
      return -$b['weight'];
    }
  }
  if(isset($a['weight'])){
   return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
  }
}
krisrobinson’s picture

#2 also worked for me... is this fixing something or just a band aid hack?

acbramley’s picture

This is most likely what was described in #1 so this patch is really just a band-aid. I'm getting the errors too on D7, I will try tracking down the module causing this.

acbramley’s picture

Also that patch is overwriting the information that is passed to the function.

Brn’s picture

Status: Closed (won't fix) » Needs work

I'm tracking this error too (drupal 6.22 with wampMSS to test PHP5.3)

What do you thing about system module at line 1725 :

// Check run-time requirements and status information.
$requirements = module_invoke_all('requirements', 'runtime');
usort($requirements, '_system_sort_requirements');
ParisLiakos’s picture

Status: Needs work » Closed (duplicate)
roberto.musa’s picture

warning: strcmp() expects parameter 2 to be string, array given in...
Resolved serializing arrays:

/**
 * Helper function to sort requirements.
 */
 
function _system_sort_requirements($a, $b) {
  if (!isset($a['weight'])) {
    if (!isset($b['weight'])) {
-     return strcmp($a['title'] ,$b['title']);
+     return strcasecmp(serialize($a['title']), serialize($b['title']));
    }
    return -$b['weight'];
  }
  return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
}