The branch, master has been updated via 3803a1cde4d153bd5d43b34e16c9eb4c44fd8183 (commit) via 3d621fd3afb302cfa14940f30bf71815a3263b8c (commit) via 5379b55691620d107ed33ee43d63727079137413 (commit) via c722d0d696125345e4ef8f0db095458a696c72d6 (commit) via 323026c0ea041dd818e0e7f0f453c7dc1ec4d3b2 (commit) from fcf2a7be85ded45e35ce805816657f98de1c4531 (commit)
- Log ----------------------------------------------------------------- commit 3803a1cde4d153bd5d43b34e16c9eb4c44fd8183 Author: Michal Čihař mcihar@suse.cz Date: Mon Aug 8 16:20:37 2011 +0200
Single call of strtr instead of three str_replace
commit 3d621fd3afb302cfa14940f30bf71815a3263b8c Author: Michal Čihař mcihar@suse.cz Date: Mon Aug 8 16:19:05 2011 +0200
Simplify replace logic
commit 5379b55691620d107ed33ee43d63727079137413 Author: Michal Čihař mcihar@suse.cz Date: Mon Aug 8 16:17:48 2011 +0200
Coding style
commit c722d0d696125345e4ef8f0db095458a696c72d6 Author: Michal Čihař mcihar@suse.cz Date: Mon Aug 8 16:16:47 2011 +0200
Simplify escape functions usint strtr
commit 323026c0ea041dd818e0e7f0f453c7dc1ec4d3b2 Author: Michal Čihař mcihar@suse.cz Date: Mon Aug 8 16:15:24 2011 +0200
Use strtr instead of str_replace and array_keys/values combo
-----------------------------------------------------------------------
Summary of changes: libraries/common.lib.php | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/libraries/common.lib.php b/libraries/common.lib.php index c83ab34..3b8a6b9 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -100,7 +100,7 @@ function PMA_getIcon($icon, $alternate = '', $force_text = false, $noSprite = fa } else { $button .= '<img src="themes/dot.gif"' . ' title="' . $alternate . '" alt="' . $alternate . '"' - . ' class="icon ic_' . str_replace(array('.gif','.png'),array('',''),$icon) . '" />'; + . ' class="icon ic_' . str_replace(array('.gif','.png'), '', $icon) . '" />'; } }
@@ -174,9 +174,10 @@ function PMA_sqlAddSlashes($a_string = '', $is_like = false, $crlf = false, $php }
if ($crlf) { - $a_string = str_replace("\n", '\n', $a_string); - $a_string = str_replace("\r", '\r', $a_string); - $a_string = str_replace("\t", '\t', $a_string); + $a_string = strtr( + $a_string, + array("\n" => '\n', "\r" => '\r', "\t" => '\t') + ); }
if ($php_code) { @@ -202,10 +203,7 @@ function PMA_sqlAddSlashes($a_string = '', $is_like = false, $crlf = false, $php */ function PMA_escape_mysql_wildcards($name) { - $name = str_replace('_', '\_', $name); - $name = str_replace('%', '\%', $name); - - return $name; + return strtr($name, array('_' => '\_', '%' => '\%')); } // end of the 'PMA_escape_mysql_wildcards()' function
/** @@ -220,10 +218,7 @@ function PMA_escape_mysql_wildcards($name) */ function PMA_unescape_mysql_wildcards($name) { - $name = str_replace('\_', '_', $name); - $name = str_replace('\%', '%', $name); - - return $name; + return strtr($name, array('\_' => '_', '\%' => '%')); } // end of the 'PMA_unescape_mysql_wildcards()' function
/** @@ -1393,7 +1388,9 @@ function PMA_formatNumber($value, $digits_left = 3, $digits_right = 0, $only_dow //number_format is not multibyte safe, str_replace is safe if ($digits_left === 0) { $value = number_format($value, $digits_right); - if ($originalValue!=0 && floatval($value) == 0) $value = ' <'.(1/PMA_pow(10,$digits_right)); + if ($originalValue != 0 && floatval($value) == 0) { + $value = ' <' . (1 / PMA_pow(10, $digits_right)); + }
return PMA_localizeNumber($value); } @@ -2927,7 +2924,7 @@ function PMA_expandUserString($string, $escape = null, $updates = array()) }
/* Do the replacement */ - return str_replace(array_keys($replace), array_values($replace), strftime($string)); + return strtr(strftime($string), $replace); }
/**
hooks/post-receive