[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-13538-g2bfaa71

Michal Čihař nijel at users.sourceforge.net
Mon Aug 8 17:13:15 CEST 2011


The branch, master has been updated
       via  2bfaa716bdb3e9e4cfa6d0a85a321328ffd7161f (commit)
       via  3d29edba96358b6ac5f494332975bb092a2b10b3 (commit)
       via  3228a5b761c0a2d48b79175f6527142cc10b9f9e (commit)
       via  53f9d89fbd7c246d424d9d696a4781ef41a66064 (commit)
      from  d2f97300d0b1115b83170be3cdaec1d0d057f7be (commit)


- Log -----------------------------------------------------------------
commit 2bfaa716bdb3e9e4cfa6d0a85a321328ffd7161f
Author: Michal Čihař <mcihar at suse.cz>
Date:   Mon Aug 8 17:12:19 2011 +0200

    Remove global variables
    
    These are used only once anyway and storing in variables looks like it
    is configurable.

commit 3d29edba96358b6ac5f494332975bb092a2b10b3
Author: Michal Čihař <mcihar at suse.cz>
Date:   Mon Aug 8 17:10:31 2011 +0200

    Remove no longer needed globals

commit 3228a5b761c0a2d48b79175f6527142cc10b9f9e
Author: Michal Čihař <mcihar at suse.cz>
Date:   Mon Aug 8 17:05:03 2011 +0200

    Avoid using GLOBALS referenced functions
    
    This actually makes performance because it needs extra lookup in
    globals.

commit 53f9d89fbd7c246d424d9d696a4781ef41a66064
Author: Michal Čihař <mcihar at suse.cz>
Date:   Mon Aug 8 16:59:31 2011 +0200

    Wrap some long lines

-----------------------------------------------------------------------

Summary of changes:
 libraries/sqlparser.lib.php |   89 ++++++++++++++++++++++++-------------------
 libraries/string.lib.php    |   24 ++----------
 2 files changed, 54 insertions(+), 59 deletions(-)

diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php
index fba2719..1037ca3 100644
--- a/libraries/sqlparser.lib.php
+++ b/libraries/sqlparser.lib.php
@@ -206,7 +206,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
      */
     function PMA_SQP_parse($sql)
     {
-        static $PMA_SQPdata_column_attrib, $PMA_SQPdata_reserved_word, $PMA_SQPdata_column_type;
+        static $PMA_SQPdata_column_attrib, $PMA_SQPdata_reserved_word;
+        static $PMA_SQPdata_column_type;
         static $PMA_SQPdata_function_name, $PMA_SQPdata_forbidden_word;
         global $mysql_charsets, $mysql_collations_flat;
 
@@ -221,11 +222,21 @@ if (! defined('PMA_MINIMUM_COMMON')) {
 
         // Create local hashtables
         if (!isset($PMA_SQPdata_column_attrib_cnt)) {
-            $PMA_SQPdata_column_attrib  = array_flip($GLOBALS['PMA_SQPdata_column_attrib']);
-            $PMA_SQPdata_function_name  = array_flip($GLOBALS['PMA_SQPdata_function_name']);
-            $PMA_SQPdata_reserved_word  = array_flip($GLOBALS['PMA_SQPdata_reserved_word']);
-            $PMA_SQPdata_forbidden_word = array_flip($GLOBALS['PMA_SQPdata_forbidden_word']);
-            $PMA_SQPdata_column_type    = array_flip($GLOBALS['PMA_SQPdata_column_type']);
+            $PMA_SQPdata_column_attrib  = array_flip(
+                $GLOBALS['PMA_SQPdata_column_attrib']
+                );
+            $PMA_SQPdata_function_name  = array_flip(
+                $GLOBALS['PMA_SQPdata_function_name']
+                );
+            $PMA_SQPdata_reserved_word  = array_flip(
+                $GLOBALS['PMA_SQPdata_reserved_word']
+                );
+            $PMA_SQPdata_forbidden_word = array_flip(
+                $GLOBALS['PMA_SQPdata_forbidden_word']
+                );
+            $PMA_SQPdata_column_type    = array_flip(
+                $GLOBALS['PMA_SQPdata_column_type']
+                );
         }
 
         $sql_array               = array();
@@ -270,7 +281,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
         $this_was_quote       = false;
 
         while ($count2 < $len) {
-            $c      = $GLOBALS['PMA_substr']($sql, $count2, 1);
+            $c      = PMA_substr($sql, $count2, 1);
             $count1 = $count2;
 
             $previous_was_space = $this_was_space;
@@ -292,7 +303,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
             }
 
             // Checks for white space
-            if ($GLOBALS['PMA_STR_isSpace']($c)) {
+            if (PMA_STR_isSpace($c)) {
                 $this_was_space = true;
                 $count2++;
                 continue;
@@ -303,9 +314,9 @@ if (! defined('PMA_MINIMUM_COMMON')) {
             // C style /* */
             // ANSI style --
             if (($c == '#')
-                || (($count2 + 1 < $len) && ($c == '/') && ($GLOBALS['PMA_substr']($sql, $count2 + 1, 1) == '*'))
-                || (($count2 + 2 == $len) && ($c == '-') && ($GLOBALS['PMA_substr']($sql, $count2 + 1, 1) == '-'))
-                || (($count2 + 2 < $len) && ($c == '-') && ($GLOBALS['PMA_substr']($sql, $count2 + 1, 1) == '-') && (($GLOBALS['PMA_substr']($sql, $count2 + 2, 1) <= ' ')))) {
+                || (($count2 + 1 < $len) && ($c == '/') && (PMA_substr($sql, $count2 + 1, 1) == '*'))
+                || (($count2 + 2 == $len) && ($c == '-') && (PMA_substr($sql, $count2 + 1, 1) == '-'))
+                || (($count2 + 2 < $len) && ($c == '-') && (PMA_substr($sql, $count2 + 1, 1) == '-') && ((PMA_substr($sql, $count2 + 2, 1) <= ' ')))) {
                 $count2++;
                 $pos  = 0;
                 $type = 'bad';
@@ -314,24 +325,24 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                     $type = 'mysql';
                 case '-':
                     $type = 'ansi';
-                    $pos  = $GLOBALS['PMA_strpos']($sql, "\n", $count2);
+                    $pos  = PMA_strpos($sql, "\n", $count2);
                     break;
                 case '/':
                     $type = 'c';
-                    $pos  = $GLOBALS['PMA_strpos']($sql, '*/', $count2);
+                    $pos  = PMA_strpos($sql, '*/', $count2);
                     $pos  += 2;
                     break;
                 default:
                     break;
                 } // end switch
                 $count2 = ($pos < $count2) ? $len : $pos;
-                $str    = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
+                $str    = PMA_substr($sql, $count1, $count2 - $count1);
                 PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
                 continue;
             } // end if
 
             // Checks for something inside quotation marks
-            if ($GLOBALS['PMA_strpos']($quote_list, $c) !== false) {
+            if (PMA_strpos($quote_list, $c) !== false) {
                 $startquotepos   = $count2;
                 $quotetype       = $c;
                 $count2++;
@@ -341,7 +352,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                 $oldpos          = 0;
                 do {
                     $oldpos = $pos;
-                    $pos    = $GLOBALS['PMA_strpos'](' ' . $sql, $quotetype, $oldpos + 1) - 1;
+                    $pos    = PMA_strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1;
                     // ($pos === false)
                     if ($pos < 0) {
                         if ($c == '`') {
@@ -355,7 +366,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                              *
                              * SELECT * FROM `table`
                              */
-                            $pos_quote_separator = $GLOBALS['PMA_strpos'](' ' . $sql, $GLOBALS['sql_delimiter'], $oldpos + 1) - 1;
+                            $pos_quote_separator = PMA_strpos(' ' . $sql, $GLOBALS['sql_delimiter'], $oldpos + 1) - 1;
                             if ($pos_quote_separator < 0) {
                                 $len += 1;
                                 $sql .= '`';
@@ -363,7 +374,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                                 $pos = $len;
                             } else {
                                 $len += 1;
-                                $sql = $GLOBALS['PMA_substr']($sql, 0, $pos_quote_separator) . '`' . $GLOBALS['PMA_substr']($sql, $pos_quote_separator);
+                                $sql = PMA_substr($sql, 0, $pos_quote_separator) . '`' . PMA_substr($sql, $pos_quote_separator);
                                 $sql_array['raw'] = $sql;
                                 $pos = $pos_quote_separator;
                             }
@@ -389,7 +400,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                     if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos) && $c != '`') {
                         $pos ++;
                         continue;
-                    } elseif (($pos + 1 < $len) && ($GLOBALS['PMA_substr']($sql, $pos, 1) == $quotetype) && ($GLOBALS['PMA_substr']($sql, $pos + 1, 1) == $quotetype)) {
+                    } elseif (($pos + 1 < $len) && (PMA_substr($sql, $pos, 1) == $quotetype) && (PMA_substr($sql, $pos + 1, 1) == $quotetype)) {
                         $pos = $pos + 2;
                         continue;
                     } else {
@@ -416,27 +427,27 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                 default:
                     break;
                 } // end switch
-                $data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
+                $data = PMA_substr($sql, $count1, $count2 - $count1);
                 PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
                 continue;
             }
 
             // Checks for brackets
-            if ($GLOBALS['PMA_strpos']($bracket_list, $c) !== false) {
+            if (PMA_strpos($bracket_list, $c) !== false) {
                 // All bracket tokens are only one item long
                 $this_was_bracket = true;
                 $count2++;
                 $type_type     = '';
-                if ($GLOBALS['PMA_strpos']('([{', $c) !== false) {
+                if (PMA_strpos('([{', $c) !== false) {
                     $type_type = 'open';
                 } else {
                     $type_type = 'close';
                 }
 
                 $type_style     = '';
-                if ($GLOBALS['PMA_strpos']('()', $c) !== false) {
+                if (PMA_strpos('()', $c) !== false) {
                     $type_style = 'round';
-                } elseif ($GLOBALS['PMA_strpos']('[]', $c) !== false) {
+                } elseif (PMA_strpos('[]', $c) !== false) {
                     $type_style = 'square';
                 } else {
                     $type_style = 'curly';
@@ -463,7 +474,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
             if (PMA_STR_isSqlIdentifier($c, false)
              || $c == '@'
              || ($c == '.'
-              && $GLOBALS['PMA_STR_isDigit']($GLOBALS['PMA_substr']($sql, $count2 + 1, 1))
+              && PMA_STR_isDigit(PMA_substr($sql, $count2 + 1, 1))
               && ($previous_was_space || $previous_was_bracket || $previous_was_listsep))) {
 
                 /* DEBUG
@@ -481,8 +492,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                 $is_identifier           = $previous_was_punct;
                 $is_sql_variable         = $c == '@' && ! $previous_was_quote;
                 $is_user                 = $c == '@' && $previous_was_quote;
-                $is_digit                = !$is_identifier && !$is_sql_variable && $GLOBALS['PMA_STR_isDigit']($c);
-                $is_hex_digit            = $is_digit && $c == '0' && $count2 < $len && $GLOBALS['PMA_substr']($sql, $count2, 1) == 'x';
+                $is_digit                = !$is_identifier && !$is_sql_variable && PMA_STR_isDigit($c);
+                $is_hex_digit            = $is_digit && $c == '0' && $count2 < $len && PMA_substr($sql, $count2, 1) == 'x';
                 $is_float_digit          = $c == '.';
                 $is_float_digit_exponent = false;
 
@@ -511,8 +522,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                     unset($pos);
                 }
 
-                while (($count2 < $len) && PMA_STR_isSqlIdentifier($GLOBALS['PMA_substr']($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
-                    $c2 = $GLOBALS['PMA_substr']($sql, $count2, 1);
+                while (($count2 < $len) && PMA_STR_isSqlIdentifier(PMA_substr($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
+                    $c2 = PMA_substr($sql, $count2, 1);
                     if ($is_sql_variable && ($c2 == '.')) {
                         $count2++;
                         continue;
@@ -540,7 +551,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                             $is_float_digit          = false;
                         }
                     }
-                    if (($is_hex_digit && PMA_STR_isHexDigit($c2)) || ($is_digit && $GLOBALS['PMA_STR_isDigit']($c2))) {
+                    if (($is_hex_digit && PMA_STR_isHexDigit($c2)) || ($is_digit && PMA_STR_isDigit($c2))) {
                         $count2++;
                         continue;
                     } else {
@@ -552,7 +563,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                 } // end while
 
                 $l    = $count2 - $count1;
-                $str  = $GLOBALS['PMA_substr']($sql, $count1, $l);
+                $str  = PMA_substr($sql, $count1, $l);
 
                 $type = '';
                 if ($is_digit || $is_float_digit || $is_hex_digit) {
@@ -577,15 +588,15 @@ if (! defined('PMA_MINIMUM_COMMON')) {
             }
 
             // Checks for punct
-            if ($GLOBALS['PMA_strpos']($allpunct_list, $c) !== false) {
-                while (($count2 < $len) && $GLOBALS['PMA_strpos']($allpunct_list, $GLOBALS['PMA_substr']($sql, $count2, 1)) !== false) {
+            if (PMA_strpos($allpunct_list, $c) !== false) {
+                while (($count2 < $len) && PMA_strpos($allpunct_list, PMA_substr($sql, $count2, 1)) !== false) {
                     $count2++;
                 }
                 $l = $count2 - $count1;
                 if ($l == 1) {
                     $punct_data = $c;
                 } else {
-                    $punct_data = $GLOBALS['PMA_substr']($sql, $count1, $l);
+                    $punct_data = PMA_substr($sql, $count1, $l);
                 }
 
                 // Special case, sometimes, althought two characters are
@@ -627,12 +638,12 @@ if (! defined('PMA_MINIMUM_COMMON')) {
                     if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) {
                         $count2     = $count1 + 1;
                         $punct_data = $first;
-                    } elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || $GLOBALS['PMA_substr']($sql, $count2, 1) <= ' '))) {
+                    } elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || PMA_substr($sql, $count2, 1) <= ' '))) {
                         $count2     -= 2;
-                        $punct_data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
+                        $punct_data = PMA_substr($sql, $count1, $count2 - $count1);
                     } elseif (($last == '-') || ($last == '+') || ($last == '!')) {
                         $count2--;
-                        $punct_data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
+                        $punct_data = PMA_substr($sql, $count1, $count2 - $count1);
                     /**
                      * @todo for negation operator, split in 2 tokens ?
                      * "select x&~1 from t"
@@ -655,7 +666,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
             $count2++;
 
             $debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len .  "\n"
-                      . 'STR: ' . $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1) . "\n";
+                      . 'STR: ' . PMA_substr($sql, $count1, $count2 - $count1) . "\n";
             PMA_SQP_bug($debugstr, $sql);
             return $sql_array;
 
@@ -2062,7 +2073,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
      */
     function PMA_SQP_formatHtml_colorize($arr)
     {
-        $i         = $GLOBALS['PMA_strpos']($arr['type'], '_');
+        $i         = PMA_strpos($arr['type'], '_');
         $class     = '';
         if ($i > 0) {
             $class = 'syntax_' . PMA_substr($arr['type'], 0, $i) . ' ';
diff --git a/libraries/string.lib.php b/libraries/string.lib.php
index 0cfef41..0e9f974 100644
--- a/libraries/string.lib.php
+++ b/libraries/string.lib.php
@@ -19,38 +19,22 @@ if (! defined('PHPMYADMIN')) {
     exit;
 }
 
-$GLOBALS['PMA_allow_mbstr'] = @function_exists('mb_strlen');
-$GLOBALS['PMA_allow_ctype'] = @extension_loaded('ctype');
-
-if ($GLOBALS['PMA_allow_mbstr']) {
-    mb_internal_encoding('utf-8');
-}
-
 /**
  * Load proper code for handling input.
  */
-if ($GLOBALS['PMA_allow_mbstr']) {
-    $GLOBALS['PMA_strpos']      = 'mb_strpos';
-    $GLOBALS['PMA_substr']      = 'mb_substr';
+if (@function_exists('mb_strlen')) {
+    mb_internal_encoding('utf-8');
     require './libraries/string_mb.lib.php';
 } else {
-    $GLOBALS['PMA_strpos']      = 'strpos';
-    $GLOBALS['PMA_substr']      = 'substr';
     require './libraries/string_native.lib.php';
 }
 
 /**
  * Load ctype handler.
  */
-if ($GLOBALS['PMA_allow_ctype']) {
-    $GLOBALS['PMA_STR_isAlnum'] = 'ctype_alnum';
-    $GLOBALS['PMA_STR_isDigit'] = 'ctype_digit';
-    $GLOBALS['PMA_STR_isSpace'] = 'ctype_space';
+if (@extension_loaded('ctype')) {
     require './libraries/string_type_ctype.lib.php';
 } else {
-    $GLOBALS['PMA_STR_isAlnum'] = 'PMA_STR_isAlnum';
-    $GLOBALS['PMA_STR_isDigit'] = 'PMA_STR_isDigit';
-    $GLOBALS['PMA_STR_isSpace'] = 'PMA_STR_isSpace';
     require './libraries/string_type_native.lib.php';
 }
 
@@ -107,7 +91,7 @@ function PMA_STR_numberInRangeInclusive($num, $lower, $upper)
  */
 function PMA_STR_isSqlIdentifier($c, $dot_is_valid = false)
 {
-    return ($GLOBALS['PMA_STR_isAlnum']($c)
+    return (PMA_STR_isAlnum($c)
         || ($ord_c = ord($c)) && $ord_c >= 192 && $ord_c != 215 && $ord_c != 249
         || $c == '_'
         || $c == '$'


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list