From c1f20fefd4c848f3b0e2ec952f60702b4237e341 Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Fri, 19 Aug 2011 18:16:14 +0200 Subject: [PATCH 1/3] Make Advisor evaluation code easier to understand --- libraries/Advisor.class.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index 61592863c0..b681155ac6 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -174,6 +174,22 @@ class Advisor $this->runResult[$type][] = $rule; } + private function ruleExprEvaluate_var1($matches) + { + // '/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie' + return '1'; //isset($this->runResult[\'fired\'] + } + + private function ruleExprEvaluate_var2($matches) + { + // '/\b(\w+)\b/e' + return isset($this->variables[$matches[1]]) + ? (is_numeric($this->variables[$matches[1]]) + ? $this->variables[$matches[1]] + : '"'.$this->variables[$matches[1]].'"') + : $matches[1]; + } + // Runs a code expression, replacing variable names with their respective values // ignoreUntil: if > 0, it doesn't replace any variables until that string position, but still evaluates the whole expr function ruleExprEvaluate($expr, $ignoreUntil = 0) @@ -182,13 +198,14 @@ class Advisor $exprIgnore = substr($expr,0,$ignoreUntil); $expr = substr($expr,$ignoreUntil); } - $expr = preg_replace('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie','1',$expr); //isset($this->runResult[\'fired\'] - $expr = preg_replace('/\b(\w+)\b/e','isset($this->variables[\'\1\']) ? (!is_numeric($this->variables[\'\1\']) ? \'"\'.$this->variables[\'\1\'].\'"\' : $this->variables[\'\1\']) : \'\1\'', $expr); + $expr = preg_replace_callback('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Ui', array($this, 'ruleExprEvaluate_var1'), $expr); + $expr = preg_replace_callback('/\b(\w+)\b/', array($this, 'ruleExprEvaluate_var2'), $expr); if ($ignoreUntil > 0) { $expr = $exprIgnore . $expr; } $value = 0; $err = 0; + ob_start(); eval('$value = '.$expr.';'); $err = ob_get_contents(); From 941c186d27b3bf6a708ce182399cea4ab6f17474 Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Fri, 19 Aug 2011 18:17:56 +0200 Subject: [PATCH 2/3] Advisor: properly detect 64-bit builds of MySQL on Windows --- 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 f13f838890..b2aa21df38 100644 --- a/libraries/advisory_rules.txt +++ b/libraries/advisory_rules.txt @@ -111,7 +111,7 @@ rule 'Distribution' rule 'MySQL Architecture' system_memory - value > 3072*1024 && !preg_match('/64/',version_compile_machine) + value > 3072*1024 && !preg_match('/64/',version_compile_machine) && !preg_match('/64/',version_compile_os) MySQL is not compiled as a 64-bit package. Your memory capacity is above 3 GiB (assuming the Server is on localhost), so MySQL might not be able to access all of your memory. You might want to consider installing the 64-bit version of MySQL. Available memory on this host: %s | implode(' ',PMA_formatByteDown(value*1024, 2, 2)) From 5e860f187467162b2995c48feaff6689ba1accd2 Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Fri, 19 Aug 2011 18:24:04 +0200 Subject: [PATCH 3/3] Fix usage of PMA_DBI_get_columns in tbl_change.php --- tbl_change.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tbl_change.php b/tbl_change.php index bf0704a899..e7011ebbf1 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -165,7 +165,7 @@ unset($show_create_table); * Get the list of the fields of the current table */ PMA_DBI_select_db($db); -$table_fields = PMA_DBI_get_columns($db, $table); +$table_fields = array_values(PMA_DBI_get_columns($db, $table)); $rows = array(); if (isset($where_clause)) { // when in edit mode load all selected rows from table