]> git.joonet.de Git - adminer.git/commitdiff
Remove function minification for performance and customization
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 27 Jul 2009 10:12:23 +0000 (10:12 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 27 Jul 2009 10:12:23 +0000 (10:12 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@912 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/functions.inc.php
adminer/include/mysql.inc.php
adminer/select.inc.php
compile.php

index 0f6d4dab0e75efd9fd484ed3807f921936d7915f..70ff66aed52e67bca2c5dffcf4e281e79935adc4 100644 (file)
@@ -365,7 +365,6 @@ function email_header($header) {
 }
 
 function call_adminer($method, $default, $arg1 = null, $arg2 = null, $arg3 = null) {
-       // maintains original method name in minification
        if (method_exists('Adminer', $method)) { // user defined class
                // can use func_get_args() and call_user_func_array()
                return Adminer::$method($arg1, $arg2, $arg3);
index a437765111cb04d2770602cf1e3caf5294428cdc..37d7724d14432b5f7c3ad91d32082477da2b9777 100644 (file)
@@ -24,63 +24,13 @@ if (extension_loaded("mysqli")) {
                        if (!$result) {
                                return false;
                        }
-                       $row = $result->_result->fetch_array();
+                       $row = $result->fetch_array();
                        return $row[$field];
                }
                
                function quote($string) {
-                       return "'" . parent::escape_string($string) . "'";
+                       return "'" . $this->escape_string($string) . "'";
                }
-               
-               // minification compatibility start
-               function select_db($database) {
-                       return parent::select_db($database);
-               }
-               
-               function query($query) {
-                       // result is packed in envelope object to allow minification
-                       $result = parent::query($query);
-                       return (is_object($result) ? new Min_Result($result) : $result);
-               }
-               
-               function multi_query($query) {
-                       return parent::multi_query($query);
-               }
-               
-               function store_result() {
-                       $result = parent::store_result();
-                       return (is_object($result) ? new Min_Result($result) : $result);
-               }
-               
-               function next_result() {
-                       return parent::next_result();
-               }
-       }
-       
-       class Min_Result {
-               var $_result, $num_rows;
-               
-               function __construct($result) {
-                       $this->_result = $result;
-                       $this->num_rows = $result->num_rows;
-               }
-               
-               function fetch_assoc() {
-                       return $this->_result->fetch_assoc();
-               }
-               
-               function fetch_row() {
-                       return $this->_result->fetch_row();
-               }
-               
-               function fetch_field() {
-                       return $this->_result->fetch_field();
-               }
-               
-               function free() {
-                       return $this->_result->free();
-               }
-               // minification compatibility end
        }
        
 } elseif (extension_loaded("mysql")) {
index 14f1c8ac97d3fd4ccbcae93beeca2416f14482a3..7d396f6109a76ce9526e5e0731856cf214e8f00f 100644 (file)
@@ -381,7 +381,7 @@ if (!$columns) {
                }
                echo "<fieldset><legend>" . lang('CSV Import') . "</legend><div><input type='hidden' name='token' value='$token'><input type='file' name='csv_file'> <input type='submit' name='import' value='" . lang('Import') . "'></div></fieldset>\n";
                
-               adminer_select_extra_display(array_filter($email_fields)); //! should use strlen but compile.php doesn't support array_filter
+               adminer_select_extra_display(array_filter($email_fields, 'strlen'));
                
                echo "</form>\n";
        }
index a2a670f82df2ef6a3fa9b873ae594fe6ad40e851..bc1681d76071bafa086e9c44a7b10cd9145e61a6 100644 (file)
@@ -80,20 +80,12 @@ function short_identifier($number, $chars) {
 function php_shrink($input) {
        $special_variables = array_flip(array('$this', '$GLOBALS', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_SERVER'));
        static $short_variables = array();
-       static $short_functions = array();
        $shortening = true;
-       $special_functions = array_flip(array('Min_DB', 'Min_Result', '__construct'));
-       $defined_functions = array();
        $tokens = token_get_all($input);
        
        foreach ($tokens as $i => $token) {
                if ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) {
                        $short_variables[$token[1]]++;
-               } elseif ($token[0] === T_STRING && $tokens[$i+1] === '(' && !isset($special_functions[$token[1]])) {
-                       $short_functions[$token[1]]++;
-                       if ($tokens[$i-2][0] === T_FUNCTION) {
-                               $defined_functions[$token[1]] = true;
-                       }
                }
        }
        
@@ -101,16 +93,6 @@ function php_shrink($input) {
        foreach (array_keys($short_variables) as $number => $key) {
                $short_variables[$key] = short_identifier($number, implode("", range('a', 'z')) . '_' . implode("", range('A', 'Z'))); // could use also numbers and \x7f-\xff
        }
-       arsort($short_functions);
-       $number = 0;
-       foreach ($short_functions as $key => $val) {
-               if (isset($defined_functions[$key])) {
-                       do {
-                               $short_functions[$key] = short_identifier($number, implode("", range('a', 'z'))); // _ not used to not collide with gettext()
-                               $number++;
-                       } while (isset($short_functions[$short_functions[$key]])); // don't overwrite existing functions
-               }
-       }
        
        $set = array_flip(preg_split('//', '!"#$&\'()*+,-./:;<=>?@[\]^`{|}'));
        $space = '';
@@ -145,15 +127,6 @@ function php_shrink($input) {
                                }
                        } elseif ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) {
                                $token[1] = '$' . $short_variables[$token[1]];
-                       } elseif ($token[0] === T_STRING && $tokens[$i+1] === '(' && isset($defined_functions[$token[1]])
-                       && $tokens[$i-1][0] !== T_DOUBLE_COLON && $tokens[$i-2][0] !== T_NEW && $tokens[$i-2][1] !== '_result' // don't substitute parent methods - used to link PHP methods only
-                       ) {
-                               $token[1] = $short_functions[$token[1]];
-                       } elseif ($token[0] == T_CONSTANT_ENCAPSED_STRING
-                       && (($tokens[$i-1] === '(' && in_array($tokens[$i-2][1], array('array_map', 'set_exception_handler'), true)) || $token[1] == "'normalize_enum'")
-                       && isset($defined_functions[substr($token[1], 1, -1)])
-                       ) { // minify callback functions too
-                               $token[1] = "'" . $short_functions[substr($token[1], 1, -1)] . "'";
                        }
                        if (isset($set[substr($output, -1)]) || isset($set[$token[1]{0}])) {
                                $space = '';