Deprecated - uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero - Matomo 4.2.1

Hi Team,

Am getting below error in the error log. Please help me to resolve this

[2021-06-04 06:41:13 UTC] [84a06] E:\Project\matomo\core\Profiler.php(80): Deprecated - uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero - Matomo 4.2.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) [internal function]: Piwik\ErrorHandler::errorHandler(),#1\core\Profiler.php(80),#2\core\FrontController.php(229),[internal function]: Piwik\FrontController->__destruct()

Hi,

Just to keep in mind that you should not have enabled enable_sql_profiler = 1 in production except for testing performance issues.

Nevertheless, this looks like a bug and should be fixed with

Thanks Lukas for your prompt reply.
Now what i am suppose to do from this github link ?

Regards,
Paresh Badgujar

Hi,

Either wait until it is merged and the fix is included in the next Matomo release.

Or if you can’t wait and want to try it out (I haven’t tested it), apply these changes to the core/Profiler.php file:

diff --git a/core/Profiler.php b/core/Profiler.php
index 1f69c242662..4b21ddc8035 100644
--- a/core/Profiler.php
+++ b/core/Profiler.php
@@ -100,12 +100,18 @@ public static function displayDbProfileReport()
 
     private static function maxSumMsFirst($a, $b)
     {
-        return $a['sum_time_ms'] < $b['sum_time_ms'];
+        if ($a['sum_time_ms'] == $b['sum_time_ms']) {
+            return 0;
+        }
+        return ($a['sum_time_ms'] < $b['sum_time_ms']) ? -1 : 1;
     }
 
     private static function sortTimeDesc($a, $b)
     {
-        return $a['sumTimeMs'] < $b['sumTimeMs'];
+        if ($a['sumTimeMs'] == $b['sumTimeMs']) {
+            return 0;
+        }
+        return ($a['sumTimeMs'] < $b['sumTimeMs']) ? -1 : 1;
     }
 
     /**

(as in replace the red lines with the green lines (without the - and +))