From 08b6d28755dbeb5e8172be847564cd61b9d24c28 Mon Sep 17 00:00:00 2001 From: Tyron Madlener Date: Fri, 12 Aug 2011 16:07:13 +0300 Subject: [PATCH 1/4] External urls from advisory_rules are redirected to url.php --- libraries/advisor.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/advisor.class.php b/libraries/advisor.class.php index 11e0119d9d..5d2ed60132 100644 --- a/libraries/advisor.class.php +++ b/libraries/advisor.class.php @@ -120,11 +120,18 @@ class Advisor $rule['name'] = _gettext($rule['name']); $rule['issue'] = _gettext($rule['issue']); + // Replaces {server_variable} with 'server_variable' linking to server_variables.php $rule['recommendation'] = preg_replace( '/\{([a-z_0-9]+)\}/Ui', - '\1', + '\1', _gettext($rule['recommendation'])); + // Replaces external Links with PMA_linkURL() generated links + $rule['recommendation'] = preg_replace( + '#href=("|\')(https?://[^\1]+)\1#ie', + '\'href="\' . PMA_linkURL("\2") . \'"\'', + $rule['recommendation'] + ); break; } From 0407bb70a9521fee3ec2fe9f301e11242b6e1ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 10:18:22 +0200 Subject: [PATCH 2/4] Param was missing --- libraries/advisory_rules.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/advisory_rules.txt b/libraries/advisory_rules.txt index dd1843665d..d50834c30c 100644 --- a/libraries/advisory_rules.txt +++ b/libraries/advisory_rules.txt @@ -422,7 +422,7 @@ rule 'InnoDB buffer pool size' [system_memory > 0] value < 60 Your InnoDB buffer pool is fairly small. The InnoDB buffer pool has a profound impact on performance for InnoDB tables. Assign all your remaining memory to this buffer. For database servers that use solely InnoDB as storage engine and have no other services (e.g. a web server) running, you may set this as high as 80% of your available memory. If that is not the case, you need to carefully assess the memory consumption of your other services and non-InnoDB-Tables and set this variable accordingly. If it is set too high, your system will start swapping, which decreases performance significantly. See also this article - You are currently using %s% of your memory for the InnoDB buffer pool. This rule fires if you are assigning less than 60%, however this might be perfectly adequate for your system if you don't have much InnoDB tables or other services running on the same machine. + You are currently using %s% of your memory for the InnoDB buffer pool. This rule fires if you are assigning less than 60%, however this might be perfectly adequate for your system if you don't have much InnoDB tables or other services running on the same machine. | value # # other From aec113c7b73a7f062cdf015fa24908b72a8180d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 10:36:01 +0200 Subject: [PATCH 3/4] Rename file to match standards --- libraries/{advisor.class.php => Advisor.class.php} | 0 libraries/advisory_rules.txt | 2 +- scripts/advisor2php | 4 ++-- server_status.php | 2 +- test/classes/Advisor_test.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename libraries/{advisor.class.php => Advisor.class.php} (100%) diff --git a/libraries/advisor.class.php b/libraries/Advisor.class.php similarity index 100% rename from libraries/advisor.class.php rename to libraries/Advisor.class.php diff --git a/libraries/advisory_rules.txt b/libraries/advisory_rules.txt index d50834c30c..f13f838890 100644 --- a/libraries/advisory_rules.txt +++ b/libraries/advisory_rules.txt @@ -1,6 +1,6 @@ # phpMyAdmin Advisory rules file # Use only UNIX style newlines -# This file is being parsed by advisor.class.php, which should handle syntax errors correctly. +# This file is being parsed by Advisor.class.php, which should handle syntax errors correctly. # However, PHP Warnings and the like are being consumed by the phpMyAdmin error handler, so those won't show up # E.g.: Justification line is empty because you used an unescape percent sign, sprintf() returns an empty string and no warning/error is shown # diff --git a/scripts/advisor2php b/scripts/advisor2php index 7bc85677db..c34f2870d1 100644 --- a/scripts/advisor2php +++ b/scripts/advisor2php @@ -5,10 +5,10 @@ * by gettext for generating po(t) files. */ -if (!file_exists('./libraries/advisor.class.php')) { +if (!file_exists('./libraries/Advisor.class.php')) { chdir('..'); } -include './libraries/advisor.class.php'; +include './libraries/Advisor.class.php'; $rules = Advisor::parseRulesFile(); diff --git a/server_status.php b/server_status.php index e7d104b5dc..1add0b6932 100644 --- a/server_status.php +++ b/server_status.php @@ -357,7 +357,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { } if(isset($_REQUEST['advisor'])) { - include('libraries/advisor.class.php'); + include('libraries/Advisor.class.php'); $advisor = new Advisor(); exit(json_encode($advisor->run())); } diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index 9bcba01c7b..79dfd7c49d 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -9,7 +9,7 @@ /* * Include to test. */ -require_once 'libraries/advisor.class.php'; +require_once 'libraries/Advisor.class.php'; class Advisor_test extends PHPUnit_Framework_TestCase { From 099be90fbafd84b0a427aed1c7f37d8f4e0d39ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 10:38:09 +0200 Subject: [PATCH 4/4] Add test for parsing --- test/classes/Advisor_test.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index 79dfd7c49d..ac43516eb1 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -29,5 +29,12 @@ class Advisor_test extends PHPUnit_Framework_TestCase array('%s% foo', '%s%% foo'), ); } + + public function testParse() + { + $advisor = new Advisor(); + $parseResult = $this->parseRulesFile(); + $this->assertEquals($parseResult['errors'], array()); + } } ?>