[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-13117-g872a2e6
Michal Čihař
nijel at users.sourceforge.net
Fri Aug 5 08:17:20 CEST 2011
The branch, master has been updated
via 872a2e60796886abe706d1d548537ecdc9bab0d4 (commit)
via d7e0002af659d066a2a227944c465bd9bb4bfe55 (commit)
via 9f029508dff53987371e7ce2a0e4d8cbae02d960 (commit)
via c3e5c3a329b2d227b7b523007634f17963bb767b (commit)
from 858e1e8059c77f4958f18d19af315518e12598c0 (commit)
- Log -----------------------------------------------------------------
commit 872a2e60796886abe706d1d548537ecdc9bab0d4
Author: Michal Čihař <michal at cihar.com>
Date: Fri Aug 5 08:17:08 2011 +0200
Remove unused variable
commit d7e0002af659d066a2a227944c465bd9bb4bfe55
Author: Michal Čihař <michal at cihar.com>
Date: Fri Aug 5 08:17:00 2011 +0200
Fix variable name
commit 9f029508dff53987371e7ce2a0e4d8cbae02d960
Author: Michal Čihař <michal at cihar.com>
Date: Fri Aug 5 08:14:27 2011 +0200
Whitespace cleanup
commit c3e5c3a329b2d227b7b523007634f17963bb767b
Author: Michal Čihař <michal at cihar.com>
Date: Fri Aug 5 08:14:21 2011 +0200
Remove unused variable
-----------------------------------------------------------------------
Summary of changes:
libraries/advisor.lib.php | 51 ++++++++++++++++++++---------------------
libraries/export/texytext.php | 4 +--
2 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/libraries/advisor.lib.php b/libraries/advisor.lib.php
index 038b4cf..660f90d 100644
--- a/libraries/advisor.lib.php
+++ b/libraries/advisor.lib.php
@@ -4,17 +4,17 @@ class Advisor {
var $variables;
var $parseResult;
var $runResult;
-
- function run() {
+
+ function run() {
// HowTo: A simple Advisory system in 3 easy steps.
-
+
// Step 1: Get some variables to evaluate on
$this->variables = array_merge(PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1), PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1));
// Step 2: Read and parse the list of rules
$this->parseResult = $this->parseRulesFile();
// Step 3: Feed the variables to the rules and let them fire. Sets $runResult
$this->runRules();
-
+
/* echo '<br/><hr>';
echo 'Total rules: '.count($this->parseResult['rules']).' <br><br>';
echo '<b>Possible performance issues</b><br/>';
@@ -29,7 +29,7 @@ class Advisor {
foreach($this->runResult['notfired'] as $rule) {
echo $rule['name'].'<br />';
}
-
+
if($this->runResult['errors'])
echo 'There were errors while testing the rules.';
*/
@@ -38,11 +38,11 @@ class Advisor {
function runRules() {
$this->runResult = array( 'fired' => array(), 'notfired' => array(), 'unchecked'=> array(), 'errors' => array() );
-
+
foreach($this->parseResult['rules'] as $rule) {
$this->variables['value'] = 0;
$precond = true;
-
+
if(isset($rule['precondition'])) {
try {
$precond = $this->ruleExprEvaluate($rule['precondition']);
@@ -51,7 +51,7 @@ class Advisor {
continue;
}
}
-
+
if(! $precond)
$this->addRule('unchecked', $rule);
else {
@@ -61,9 +61,9 @@ class Advisor {
$this->runResult['errors'][] = 'Failed calculating value for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
continue;
}
-
+
$this->variables['value'] = $value;
-
+
try {
if($this->ruleExprEvaluate($rule['test']))
$this->addRule('fired', $rule);
@@ -73,10 +73,10 @@ class Advisor {
}
}
}
-
+
return true;
}
-
+
function addRule($type, $rule) {
switch($type) {
case 'notfired':
@@ -90,12 +90,12 @@ class Advisor {
$this->runResult['errors'][] = 'Failed formattingstring for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage();
return;
}
-
+
$rule['justification'] = $str;
}
break;
}
-
+
$this->runResult[$type][] = $rule;
}
@@ -106,9 +106,8 @@ class Advisor {
$exprIgnore = substr($expr,0,$ignoreUntil);
$expr = substr($expr,$ignoreUntil);
}
- $old=$expr;
$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('/\b(\w+)\b/e','isset($this->variables[\'\1\']) ? (!is_numeric($this->variables[\'\1\']) ? \'"\'.$this->variables[\'\1\'].\'"\' : $this->variables[\'\1\']) : \'\1\'', $expr);
if($ignoreUntil > 0){
$expr = $exprIgnore . $expr;
}
@@ -131,7 +130,7 @@ class Advisor {
$numLines = count($file);
$j = -1;
$ruleLine = -1;
-
+
for ($i = 0; $i<$numLines; $i++) {
$line = $file[$i];
if($line[0] == '#' || $line[0] == "\n") continue;
@@ -151,7 +150,7 @@ class Advisor {
} else {
if($ruleLine == -1) $errors[] = 'Unexpected characters on line '.($i+1);
}
-
+
// Reading rule lines
if($ruleLine > 0) {
if(!isset($line[0])) continue; // Empty lines are ok
@@ -165,7 +164,7 @@ class Advisor {
$ruleLine = -1;
}
}
-
+
return array('rules' => $rules, 'errors' => $errors);
}
}
@@ -174,25 +173,25 @@ function PMA_bytime($num, $precision) {
$per = '';
if ($num >= 1) { # per second
$per = "per second";
- }
+ }
elseif ($num*60 >= 1) { # per minute
$num = $num*60;
$per = "per minute";
- }
+ }
elseif ($num*60*60 >=1 ) { # per hour
$num = $num*60*60;
$per = "per hour";
- }
+ }
else {
$num = $num*60*60*24;
$per = "per day";
}
-
+
$num = round($num, $precision);
-
+
if($num == 0) $num = '<'.pow(10,-$precision);
-
+
return "$num $per";
}
-?>
\ No newline at end of file
+?>
diff --git a/libraries/export/texytext.php b/libraries/export/texytext.php
index d24a8b2..c686c24 100644
--- a/libraries/export/texytext.php
+++ b/libraries/export/texytext.php
@@ -253,14 +253,12 @@ if (isset($plugin_list)) {
$text_output = '';
- $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
+ $extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = $extracted_fieldspec['print_type'];
if (empty($type)) {
$type = ' ';
}
- $attribute = $extracted_fieldspec['attribute'];
-
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
hooks/post-receive
--
phpMyAdmin
More information about the Git
mailing list