'; $error .= __('Logout and try as another user.') . ''; } elseif ($error_number == 1005) { if (str_contains($error_message, 'errno: 13')) { $error .= ' - ' . $error_message; $error .= $separator . __('Please check privileges of directory containing database.'); } else { /** * InnoDB constraints, see * https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html */ $error .= ' - ' . $error_message . ' (' . __('Details…') . ')'; } } else { $error .= ' - ' . $error_message; } return $error; } /** * usort comparison callback * * @param array $a first argument to sort * @param array $b second argument to sort * @param string $sortBy Key to sort by * @param string $sortOrder The order (ASC/DESC) * * @return int a value representing whether $a should be before $b in the * sorted array or not */ public static function usortComparisonCallback(array $a, array $b, string $sortBy, string $sortOrder): int { global $cfg; /* No sorting when key is not present */ if (! isset($a[$sortBy], $b[$sortBy])) { return 0; } // produces f.e.: // return -1 * strnatcasecmp($a['SCHEMA_TABLES'], $b['SCHEMA_TABLES']) $compare = $cfg['NaturalOrder'] ? strnatcasecmp( (string) $a[$sortBy], (string) $b[$sortBy] ) : strcasecmp( (string) $a[$sortBy], (string) $b[$sortBy] ); return ($sortOrder === 'ASC' ? 1 : -1) * $compare; } /** * Convert version string to integer. * * @param string $version MySQL server version */ public static function versionToInt(string $version): int { $match = explode('.', $version); return (int) sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])); } /** * Stores query data into session data for debugging purposes * * @param string $query Query text * @param string|null $errorMessage Error message from getError() * @param ResultInterface|false $result Query result * @param int|float $time Time to execute query */ public static function debugLogQueryIntoSession(string $query, ?string $errorMessage, $result, $time): void { $dbgInfo = []; if ($result === false && $errorMessage !== null) { $dbgInfo['error'] = '' . htmlspecialchars($errorMessage) . ''; } $dbgInfo['query'] = htmlspecialchars($query); $dbgInfo['time'] = $time; // Get and slightly format backtrace, this is used // in the javascript console. // Strip call to debugLogQueryIntoSession $dbgInfo['trace'] = Error::processBacktrace( array_slice(debug_backtrace(), 1) ); $dbgInfo['hash'] = md5($query); $_SESSION['debug']['queries'][] = $dbgInfo; } }