In wfArrayDiff2_cmp only compare $a and $b as string if they both are strings
authorReedy <reedy@wikimedia.org>
Fri, 27 Sep 2013 19:10:33 +0000 (20:10 +0100)
committerReedy <reedy@wikimedia.org>
Fri, 27 Sep 2013 19:15:21 +0000 (20:15 +0100)
Noticed during bug 54662

Warning: strcmp() expects parameter 2 to be string, array given in
/usr/local/apache/common-local/php-1.22wmf19/includes/GlobalFunctions.php on
line 127

Bug: 54662
Change-Id: Icdd7fa229e49d7e83aa2a7992895f497806448e1

includes/GlobalFunctions.php

index 414c822..ee88ac0 100644 (file)
@@ -118,12 +118,12 @@ function wfArrayDiff2( $a, $b ) {
 }
 
 /**
- * @param $a
- * @param $b
+ * @param $a array|string
+ * @param $b array|string
  * @return int
  */
 function wfArrayDiff2_cmp( $a, $b ) {
-       if ( !is_array( $a ) ) {
+       if ( is_string( $a ) && is_string( $b ) ) {
                return strcmp( $a, $b );
        } elseif ( count( $a ) !== count( $b ) ) {
                return count( $a ) < count( $b ) ? -1 : 1;