diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index e6a9e294dc..e3a0ac33bf 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -3093,11 +3093,18 @@ class Util $hex = bin2hex($data); $spatialAsText = 'ASTEXT'; $spatialSrid = 'SRID'; - if ($GLOBALS['dbi']->getVersion() >= 50600) { + $axisOrder = ''; + $mysqlVersionInt = $GLOBALS['dbi']->getVersion(); + if ($mysqlVersionInt >= 50600) { $spatialAsText = 'ST_ASTEXT'; $spatialSrid = 'ST_SRID'; } - $wktsql = "SELECT $spatialAsText(x'" . $hex . "')"; + + if ($mysqlVersionInt >= 80010 && ! $GLOBALS['dbi']->isMariaDb()) { + $axisOrder = ', \'axis-order=long-lat\''; + } + + $wktsql = 'SELECT ' . $spatialAsText . "(x'" . $hex . "'" . $axisOrder . ")"; if ($includeSRID) { $wktsql .= ", $spatialSrid(x'" . $hex . "')"; } diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php index 1ee439ce24..f1b379d351 100644 --- a/test/classes/UtilTest.php +++ b/test/classes/UtilTest.php @@ -2948,6 +2948,46 @@ class UtilTest extends PmaTestCase true, 50700, ], + [ + 'SELECT ST_ASTEXT(x\'000000000101000000000000000000f03f000000000000f03f\', \'axis-order=long-lat\'), ST_SRID(x\'000000000101000000000000000000f03f000000000000f03f\')', + [ + 'POINT(1 1)', + '0', + ], + '\'POINT(1 1)\',0', + true, + 80010, + ], + [ + 'SELECT ST_ASTEXT(x\'000000000101000000000000000000f03f000000000000f03f\'), ST_SRID(x\'000000000101000000000000000000f03f000000000000f03f\')', + [ + 'POINT(1 1)', + '0', + ], + '\'POINT(1 1)\',0', + true, + 50700, + ], + [ + 'SELECT ST_ASTEXT(x\'000000000101000000000000000000f03f000000000000f03f\', \'axis-order=long-lat\')', + [ + 'POINT(1 1)', + '0', + ], + 'POINT(1 1)', + false, + 80010, + ], + [ + 'SELECT ST_ASTEXT(x\'000000000101000000000000000000f03f000000000000f03f\')', + [ + 'POINT(1 1)', + '0', + ], + 'POINT(1 1)', + false, + 50700, + ], ]; } @@ -2959,7 +2999,7 @@ class UtilTest extends PmaTestCase * @param string $expectedQuery The query to expect * @param array $returnData The data to return for fetchRow * @param string $functionResult Result of the Util::asWKT invocation - * @param string $SRIDOption Use the SRID option or not + * @param bool $SRIDOption Use the SRID option or not * @param int $mysqlVersion The mysql version to return for getVersion * * @return void