Skip to content

Commit

Permalink
Merge branch 'QA_5_0'
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Oct 13, 2020
2 parents bd99f52 + 55f493d commit 0d97b16
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 8 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ phpMyAdmin - ChangeLog
- issue #14795 Include routines in the export in a predictable order

5.0.4 (not yet released)
- issue #16245 Fix failed Zoom search clears existing values
- issue Fixed a PHP error when reporting a particular JS error
- issue #16326 Fixed latitude and longitude swap for geometries in edit mode

5.0.3 (2020-10-09)
- issue #15983 Require twig ^2.9
Expand Down
3 changes: 3 additions & 0 deletions js/vendor/jquery/jquery.sortableTable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* This file is internal to phpMyAdmin.
* @license see the main phpMyAdmin license.
*
* @fileoverview A jquery plugin that allows drag&drop sorting in tables.
* Coded because JQuery UI sortable doesn't support tables. Also it has no animation
*
Expand Down
5 changes: 4 additions & 1 deletion libraries/classes/ErrorReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ public function getData(string $exceptionType = 'js'): array
return [];
}
$exception = $_POST['exception'];
$exception['stack'] = $this->translateStacktrace($exception['stack']);

if (isset($exception['stack'])) {
$exception['stack'] = $this->translateStacktrace($exception['stack']);
}

if (isset($exception['url'])) {
[$uri, $scriptName] = $this->sanitizeUrl($exception['url']);
Expand Down
11 changes: 9 additions & 2 deletions libraries/classes/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1710,11 +1710,18 @@ public static function asWKT($data, $includeSRID = false)
$hex = bin2hex($data);
$spatialAsText = 'ASTEXT';
$spatialSrid = 'SRID';
if ($dbi->getVersion() >= 50600) {
$axisOrder = '';
$mysqlVersionInt = $dbi->getVersion();
if ($mysqlVersionInt >= 50600) {
$spatialAsText = 'ST_ASTEXT';
$spatialSrid = 'ST_SRID';
}
$wktsql = 'SELECT ' . $spatialAsText . "(x'" . $hex . "')";

if ($mysqlVersionInt >= 80010 && ! $dbi->isMariaDb()) {
$axisOrder = ', \'axis-order=long-lat\'';
}

$wktsql = 'SELECT ' . $spatialAsText . "(x'" . $hex . "'" . $axisOrder . ')';
if ($includeSRID) {
$wktsql .= ', ' . $spatialSrid . "(x'" . $hex . "')";
}
Expand Down
11 changes: 6 additions & 5 deletions templates/table/zoom_search/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@
{% if criteria_column_names[i] is defined and criteria_column_names[i] != 'pma_null' %}
{% set key = keys[criteria_column_names[i]] %}
{% set properties = self.getColumnProperties(i, key) %}
{% set type = type|merge({i: properties['type']}) %}
{% set collation = collation|merge({i: properties['collation']}) %}
{% set func = func|merge({i: properties['func']}) %}
{% set value = value|merge({i: properties['value']}) %}
{% set type = type|merge({(i): properties['type']}) %}
{% set collation = collation|merge({(i): properties['collation']}) %}
{% set func = func|merge({(i): properties['func']}) %}
{% set value = value|merge({(i): properties['value']}) %}
{% endif %}
{# Column type #}
<td dir="ltr">
Expand All @@ -97,9 +97,10 @@
{{ func[i] is defined ? func[i]|raw }}
</td>
{# Inputbox for search criteria value #}
<td></td>
<td>
{{ value[i] is defined ? value[i]|raw }}
</td>
<td>
{# Displays hidden fields #}
<input type="hidden" name="criteriaColumnTypes[{{ i }}]" id="types_{{ i }}"
{%- if criteria_column_types[i] is defined %} value="{{ criteria_column_types[i] }}"{% endif %}>
Expand Down
2 changes: 2 additions & 0 deletions test/classes/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ public function testGetUserValue(): void

/**
* Should test getting unique value for theme
*
* @group 32bit-incompatible
*/
public function testGetThemeUniqueValue(): void
{
Expand Down
2 changes: 2 additions & 0 deletions test/classes/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ public function testFatalErrorMessageWithArgs(): void
* @param string $size Size
* @param int $expected Expected value
*
* @group 32bit-incompatible
*
* @dataProvider providerTestGetRealSize
*/
public function testGetRealSize(string $size, int $expected): void
Expand Down
141 changes: 141 additions & 0 deletions test/classes/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace PhpMyAdmin\Tests;

use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\MoTranslator\Loader;
use PhpMyAdmin\SqlParser\Context;
use PhpMyAdmin\SqlParser\Token;
Expand All @@ -17,6 +18,7 @@
use function date_default_timezone_set;
use function file_exists;
use function floatval;
use function hex2bin;
use function htmlspecialchars;
use function ini_get;
use function ini_set;
Expand Down Expand Up @@ -2156,4 +2158,143 @@ public function providerForwardedHeaders(): array
]*/
];
}

/**
* Some data to test Util::asWKT for testAsWKT
*/
public function dataProviderAsWKT(): array
{
return [
[
'SELECT ASTEXT(x\'000000000101000000000000000000f03f000000000000f03f\')',
['POINT(1 1)'],
'POINT(1 1)',
false,
50300,
],
[
'SELECT ASTEXT(x\'000000000101000000000000000000f03f000000000000f03f\'),'
. ' SRID(x\'000000000101000000000000000000f03f000000000000f03f\')',
[
'POINT(1 1)',
'0',
],
'\'POINT(1 1)\',0',
true,
50300,
],
[
'SELECT ST_ASTEXT(x\'000000000101000000000000000000f03f000000000000f03f\')',
['POINT(1 1)'],
'POINT(1 1)',
false,
50700,
],
[
'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\'),'
. ' 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,
],
];
}

/**
* Test to get data asWKT
*
* @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 bool $SRIDOption Use the SRID option or not
* @param int $mysqlVersion The mysql version to return for getVersion
*
* @dataProvider dataProviderAsWKT
*/
public function testAsWKT(
string $expectedQuery,
array $returnData,
string $functionResult,
bool $SRIDOption,
int $mysqlVersion
): void {
$oldDbi = $GLOBALS['dbi'];
$dbi = $this->getMockBuilder(DatabaseInterface::class)
->disableOriginalConstructor()
->getMock();

$dbi->expects($SRIDOption ? $this->once() : $this->exactly(2))
->method('getVersion')
->will($this->returnValue($mysqlVersion));

$dbi->expects($SRIDOption ? $this->once() : $this->exactly(2))
->method('tryQuery')
->with($expectedQuery)
->will($this->returnValue([]));// Omit the real object

$dbi->expects($SRIDOption ? $this->once() : $this->exactly(2))
->method('fetchRow')
->will($this->returnValue($returnData));

$GLOBALS['dbi'] = $dbi;

if (! $SRIDOption) {
// Also test default signature
$this->assertSame($functionResult, Util::asWKT(
(string) hex2bin('000000000101000000000000000000F03F000000000000F03F')
));
}
$this->assertSame($functionResult, Util::asWKT(
(string) hex2bin('000000000101000000000000000000F03F000000000000F03F'),
$SRIDOption
));

$GLOBALS['dbi'] = $oldDbi;
}
}

0 comments on commit 0d97b16

Please sign in to comment.