From bb597f73417539328216d1955e9f582723259bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 2 May 2013 10:26:21 +0200 Subject: [PATCH 1/2] Add one more test for advisor --- 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 c3c44186e6..e5cf9bb934 100644 --- a/test/classes/PMA_Advisor_test.php +++ b/test/classes/PMA_Advisor_test.php @@ -178,6 +178,22 @@ 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\'', ), + array( + array( + 'justification' => 'Version string (%s) | value', + 'name' => 'Distribution', + 'issue' => 'official MySQL binaries.', + 'recommendation' => 'See web', + ), + array( + 'justification' => 'Version string (0)', + 'name' => 'Distribution', + 'issue' => 'official MySQL binaries.', + 'recommendation' => 'See web', + 'id' => 'Distribution' + ), + null, + ), ); } } From a00b2f99a51173d70e58cd5152686e8bb6e5f3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 2 May 2013 10:28:37 +0200 Subject: [PATCH 2/2] Use preg_replace_callback instead of deprecated /e modifier This causes deprecation warning in PHP 5.5 --- libraries/Advisor.class.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index 98e090e515..91c8bf2beb 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -244,9 +244,9 @@ class Advisor ); // Replaces external Links with PMA_linkURL() generated links - $rule['recommendation'] = preg_replace( - '#href=("|\')(https?://[^\1]+)\1#ie', - '\'href="\' . PMA_linkURL("\2") . \'"\'', + $rule['recommendation'] = preg_replace_callback( + '#href=("|\')(https?://[^\1]+)\1#i', + array($this, '_replaceLinkURL'), $rule['recommendation'] ); break; @@ -255,6 +255,18 @@ class Advisor $this->runResult[$type][] = $rule; } + /** + * Callback for wrapping links with PMA_linkURL + * + * @param array $matches List of matched elements form preg_replace_callback + * + * @return Replacement value + */ + private function _replaceLinkURL($matches) + { + return 'href="' . PMA_linkURL($matches[2]) . '"'; + } + /** * Callback for evaluating fired() condition. *