From 58fcc7bb32046a36db0c7be0fdff6529baba639e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 2 Apr 2014 09:08:24 +0200 Subject: [PATCH 1/2] Add test for double format values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bug #4347 Signed-off-by: Michal Čihař --- test/classes/PMA_Advisor_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/classes/PMA_Advisor_test.php b/test/classes/PMA_Advisor_test.php index a13c68c698..aee454118f 100644 --- a/test/classes/PMA_Advisor_test.php +++ b/test/classes/PMA_Advisor_test.php @@ -210,6 +210,22 @@ class Advisor_Test extends PHPUnit_Framework_TestCase ), null, ), + array( + array( + 'justification' => '%s% %d foo | value, value', + 'name' => 'Double', + 'issue' => 'issue', + 'recommendation' => 'Recommend' + ), + array( + 'justification' => '0% 0 foo', + 'id' => 'Double', + 'name' => 'Double', + 'issue' => 'issue', + 'recommendation' => 'Recommend' + ), + null, + ), array( array( 'justification' => '"\'foo', From b80e73979b7e003659eb839916d5b2f9324ca814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 2 Apr 2014 09:14:07 +0200 Subject: [PATCH 2/2] Fixed PHP Parse error in Advisor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is one rule which needs to pass more values to format string and the code did not properly handle this. Now evaluating params and passing them to vsprintf to process the format string. Signed-off-by: Michal Čihař --- ChangeLog | 1 + libraries/Advisor.class.php | 6 ++++-- test/classes/PMA_Advisor_test.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e24330951..8469829b63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ phpMyAdmin - ChangeLog - bug #4336 List server css style wrong - bug #4345 Privileges editor shows databases with underscore backslash-escaped - bug Missing value on the Status > Server page +- bug #4347 Fixed PHP Parse error in Advisor 4.1.12.0 (2014-03-27) - bug #4334 Add event : datepicker won't open diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index 0512927549..f905d4c037 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -176,9 +176,11 @@ class Advisor { $string = _gettext(Advisor::escapePercent($str)); if ( ! is_null($param)) { - $param = $this->ruleExprEvaluate($param); + $params = $this->ruleExprEvaluate('array('. $param . ')'); + } else { + $params = array(); } - return sprintf($string, $param); + return vsprintf($string, $params); } /** diff --git a/test/classes/PMA_Advisor_test.php b/test/classes/PMA_Advisor_test.php index aee454118f..8558da8c8d 100644 --- a/test/classes/PMA_Advisor_test.php +++ b/test/classes/PMA_Advisor_test.php @@ -252,7 +252,7 @@ class Advisor_Test extends PHPUnit_Framework_TestCase array(), 'Failed formatting string for rule \'Failure\'. PHP threw ' . 'following error: Use of undefined constant fsafdsa - ' . - 'assumed \'fsafdsa\'
Executed code: $value = fsafdsa;', + 'assumed \'fsafdsa\'
Executed code: $value = array(fsafdsa);', ), array( array(