0

Updated php version 7 to 8.0.3 and the following error pops up when opening the MySQL database

Fatal error: Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e) in C:\xampp\phpMyAdmin\libraries\classes\DatabaseInterface.php on line 578

foreach ($tables as $one_database_name => $one_database_tables) {
                    uasort(
                        $one_database_tables,
                        function ($a, $b) {
                            $aLength = $a['Data_length'] + $a['Index_length'];
577                         $bLength = $b['Data_length'] + $b['Index_length'];
**578                         return ($aLength == $bLength)**
579                                ? 0
                                : ($aLength < $bLength) ? -1 : 1;
                        }
                    );
Nafil
  • 1
  • 1
  • Does this answer your question? [PHP Error : Unparenthesized \`a ? b : c ? d : e\` is deprecated. Use either \`(a ? b : c) ? d : e\` or \`a ? b : (c ? d : e)\`](https://stackoverflow.com/questions/61432488/php-error-unparenthesized-a-b-c-d-e-is-deprecated-use-either-a) – Sebastian Simon Apr 06 '21 at 02:17

1 Answers1

1

The code you're using is a nested ternary expression. The form you have is a PHP idiom, but because it can be ambiguous its use is now prohibited. If you add appropriate parentheses to remove the ambiguity you'd be fine.

You could add the required parentheses, but there's a better way - use a spaceship operator.

Replace all of

return ($aLength == $bLength)
                                ? 0
                                : ($aLength < $bLength) ? -1 : 1;

with

return ($aLength <=> $bLength);