KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

PHP8.1 PivotMatrix Sort bug #3118

Closed Keith Burke opened this topic on on Aug 10, 2023 - 2 comments

Keith Burke commented on Aug 10, 2023

I'm working on migrating all of my sites from PHP74 to PHP82. At the moment, I've successfully migrated to PHP8.1 but found one remaining possible bug in PivotMatrix Sort.

When I add a rowSort to a PivotMatrix I get an error

                    "rowSort" => array(
                        'entryDate' => function($v1, $v2) {
                            return $v1 > $v2; // -1, 0, or 1
                        }
                    ),

The Error

ErrorException

usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero

VENDORPATH/koolreport/pivot/PivotUtil.php at line 198
198         usort($index, $compareFunc); 
Sebastian Morales commented on Aug 14, 2023

I think the latest version 9.0.3 of Pivot package has fixed this issue by converting the sort function's result to integer. If you still use an older version you can try to update your sort function from:

                    "rowSort" => array(
                        'entryDate' => function($v1, $v2) {
                            return $v1 > $v2; // -1, 0, or 1
                        }
                    ),

to:

                    "rowSort" => array(
                        'entryDate' => function($v1, $v2) {
                            if ($v1 === $v2) return 0;
                            else return $v1 > $v2 ? 1 : -1;
                        }
                    ),
Keith Burke commented on Aug 14, 2023

Sebastion,

Thanks for your help. You are correct. It turned out that my composer token had expired and composer update wasn't updating KRP

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
bug

Pivot