[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-8855-g8a2d7fb

Rouslan Placella roccivic at users.sourceforge.net
Sat Jul 16 20:37:46 CEST 2011


The branch, master has been updated
       via  8a2d7fbc22bdc58aa4f4bb488b724c1bab6a3c52 (commit)
       via  47f4e0772d4de3880bd8fbfb7f547771b968b270 (commit)
       via  bdb3423bc9f11ecf6d893dd749891aabbe85bd3c (commit)
       via  d8b14b5dc745d7bc0bc79740887a3790c85f08dc (commit)
       via  6d714e5d7da833217a05a10598dca0a88a08ad39 (commit)
       via  28881e4f4a66adea4d5efd5acb97027810b23d45 (commit)
       via  62859c653e7cb1a6a13b90e7b8f6ca1fa557b3a0 (commit)
       via  526419d1a127ff0784df634eaf0ee2f4f73a6474 (commit)
      from  10fa6c5e255f3b631c7d64950baa5005236e45e3 (commit)


- Log -----------------------------------------------------------------
commit 8a2d7fbc22bdc58aa4f4bb488b724c1bab6a3c52
Merge: 10fa6c5e255f3b631c7d64950baa5005236e45e3 47f4e0772d4de3880bd8fbfb7f547771b968b270
Author: Rouslan Placella <rouslan at placella.com>
Date:   Sat Jul 16 19:35:45 2011 +0100

    Merge branch 'rte'

commit 47f4e0772d4de3880bd8fbfb7f547771b968b270
Author: Rouslan Placella <rouslan at placella.com>
Date:   Sat Jul 16 19:35:02 2011 +0100

    Better validation of parameter types when generating a CREATE ROUTINE query

commit bdb3423bc9f11ecf6d893dd749891aabbe85bd3c
Author: Rouslan Placella <rouslan at placella.com>
Date:   Sat Jul 16 19:34:17 2011 +0100

    Validate parameter direction when generating a CREATE PROCEDURE query

commit d8b14b5dc745d7bc0bc79740887a3790c85f08dc
Author: Rouslan Placella <rouslan at placella.com>
Date:   Sat Jul 16 19:33:08 2011 +0100

    Removed redundant whitespaces from CREATE ROUTINE query

commit 6d714e5d7da833217a05a10598dca0a88a08ad39
Author: Rouslan Placella <rouslan at placella.com>
Date:   Sat Jul 16 19:32:29 2011 +0100

    E_ALL fix when generating CREATE ROUTINE query from empty request

commit 28881e4f4a66adea4d5efd5acb97027810b23d45
Author: Rouslan Placella <rouslan at placella.com>
Date:   Sat Jul 16 19:31:36 2011 +0100

    Simplified check for maximum number of routine parameters

commit 62859c653e7cb1a6a13b90e7b8f6ca1fa557b3a0
Merge: 526419d1a127ff0784df634eaf0ee2f4f73a6474 10cbf3bd6051838e4e10f0b80d6be6fb35e562ab
Author: Rouslan Placella <rouslan at placella.com>
Date:   Fri Jul 15 20:41:58 2011 +0100

    Merge branch 'master' into rte
    
    Conflicts:
    	libraries/rte/rte_events.lib.php
    	libraries/rte/rte_routines.lib.php
    	libraries/rte/rte_triggers.lib.php

commit 526419d1a127ff0784df634eaf0ee2f4f73a6474
Author: Rouslan Placella <rouslan at placella.com>
Date:   Thu Jul 14 13:57:05 2011 +0100

    Renamed some functions to avoid conflicts of redefinition in unit tests

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

Summary of changes:
 db_events.php                      |    1 +
 db_routines.php                    |    1 +
 db_triggers.php                    |    1 +
 libraries/rte/rte_events.lib.php   |   28 +-------
 libraries/rte/rte_main.inc.php     |   20 ++++--
 libraries/rte/rte_routines.lib.php |  127 +++++++++---------------------------
 libraries/rte/rte_triggers.lib.php |   28 +-------
 libraries/rte/rte_words.lib.php    |   60 +++++++++++++++++
 8 files changed, 111 insertions(+), 155 deletions(-)
 create mode 100644 libraries/rte/rte_words.lib.php

diff --git a/db_events.php b/db_events.php
index f659607..c4397e7 100644
--- a/db_events.php
+++ b/db_events.php
@@ -28,6 +28,7 @@ require_once './libraries/rte/rte_events.lib.php';
 /**
  * Do the magic
  */
+$_PMA_RTE = 'EVN';
 require_once './libraries/rte/rte_main.inc.php';
 
 ?>
diff --git a/db_routines.php b/db_routines.php
index efac9ea..739e69a 100644
--- a/db_routines.php
+++ b/db_routines.php
@@ -30,6 +30,7 @@ require_once './libraries/rte/rte_routines.lib.php';
 /**
  * Do the magic
  */
+$_PMA_RTE = 'RTN';
 require_once './libraries/rte/rte_main.inc.php';
 
 ?>
diff --git a/db_triggers.php b/db_triggers.php
index 1bd792e..aef1642 100644
--- a/db_triggers.php
+++ b/db_triggers.php
@@ -27,6 +27,7 @@ require_once './libraries/rte/rte_triggers.lib.php';
 /**
  * Do the magic
  */
+$_PMA_RTE = 'TRI';
 require_once './libraries/rte/rte_main.inc.php';
 
 ?>
diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php
index 97ebcdd..a449ff2 100644
--- a/libraries/rte/rte_events.lib.php
+++ b/libraries/rte/rte_events.lib.php
@@ -44,33 +44,9 @@ function PMA_EVN_setGlobals()
 }
 
 /**
- * This function is defined in: rte_routines.lib.php, rte_triggers.lib.php and
- * rte_events.lib.php. It is used to retreive some language strings that are
- * used in functionalities that are common to routines, triggers and events.
- *
- * @param   string  $index   The index of the string to get
- *
- * @return  string  The requested string or an empty string, if not available
- */
-function PMA_RTE_getWord($index)
-{
-    $words = array(
-        'add'       => __('Add event'),
-        'docu'      => 'EVENTS',
-        'export'    => __('Export of event %s'),
-        'human'     => __('event'),
-        'no_create' => __('You do not have the necessary privileges to create an event'),
-        'not_found' => __('No event with name %1$s found in database %2$s'),
-        'nothing'   => __('There are no events to display.'),
-        'title'     => __('Events'),
-    );
-    return isset($words[$index]) ? $words[$index] : '';
-} // end PMA_RTE_getWord()
-
-/**
  * Main function for the events functionality
  */
-function PMA_RTE_main()
+function PMA_EVN_main()
 {
     global $db;
 
@@ -95,7 +71,7 @@ function PMA_RTE_main()
      * toggle the state of the event scheduler.
      */
     echo PMA_EVN_getFooterLinks();
-} // end PMA_RTE_main()
+} // end PMA_EVN_main()
 
 /**
  * Handles editor requests for adding or editing an item
diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php
index dd3e4c0..d2950bf 100644
--- a/libraries/rte/rte_main.inc.php
+++ b/libraries/rte/rte_main.inc.php
@@ -13,6 +13,7 @@ if (! defined('PHPMYADMIN')) {
  * Include all other files that are common
  * to routines, triggers and events.
  */
+require_once './libraries/rte/rte_words.lib.php';
 require_once './libraries/rte/rte_export.lib.php';
 require_once './libraries/rte/rte_list.lib.php';
 require_once './libraries/rte/rte_footer.lib.php';
@@ -71,14 +72,21 @@ $titles = PMA_buildActionTitles();
  */
 $errors = array();
 
+
 /**
- * The below function is defined in rte_routines.lib.php,
- * rte_triggers.lib.php and rte_events.lib.php
- *
- * The appropriate function will now be called based on which one
- * of these files was included earlier in the top-level folder
+ * Call the appropriate main function
  */
-PMA_RTE_main();
+switch ($_PMA_RTE) {
+case 'RTN':
+    PMA_RTN_main();
+	break;
+case 'TRI':
+    PMA_TRI_main();
+	break;
+case 'EVN':
+    PMA_EVN_main();
+	break;
+}
 
 /**
  * Display the footer, if necessary
diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php
index 8c04d85..9a99b8c 100644
--- a/libraries/rte/rte_routines.lib.php
+++ b/libraries/rte/rte_routines.lib.php
@@ -29,33 +29,9 @@ function PMA_RTN_setGlobals()
 }
 
 /**
- * This function is defined in: rte_routines.lib.php, rte_triggers.lib.php and
- * rte_events.lib.php. It is used to retreive some language strings that are
- * used in functionalities that are common to routines, triggers and events.
- *
- * @param   string  $index   The index of the string to get
- *
- * @return  string  The requested string or an empty string, if not available
- */
-function PMA_RTE_getWord($index)
-{
-    $words = array(
-        'add'       => __('Add routine'),
-        'docu'      => 'STORED_ROUTINES',
-        'export'    => __('Export of routine %s'),
-        'human'     => __('routine'),
-        'no_create' => __('You do not have the necessary privileges to create a routine'),
-        'not_found' => __('No routine with name %1$s found in database %2$s'),
-        'nothing'   => __('There are no routines to display.'),
-        'title'     => __('Routines'),
-    );
-    return isset($words[$index]) ? $words[$index] : '';
-} // end PMA_RTE_getWord()
-
-/**
  * Main function for the routines functionality
  */
-function PMA_RTE_main()
+function PMA_RTN_main()
 {
     global $db;
 
@@ -93,7 +69,7 @@ function PMA_RTE_main()
             E_USER_WARNING
         );
     }
-} // end PMA_RTE_main()
+} // end PMA_RTN_main()
 
 /**
  * This function parses a string containing one parameter of a routine,
@@ -130,8 +106,7 @@ function PMA_RTN_parseOneParameter($value)
     $param_opts = array();
     for ($i=$pos; $i<$parsed_param['len']; $i++) {
         if (($parsed_param[$i]['type'] == 'alpha_columnType'
-            || $parsed_param[$i]['type'] == 'alpha_functionName') // "CHAR" seems to be mistaken for a function by the parser
-            && $depth == 0
+            || $parsed_param[$i]['type'] == 'alpha_functionName') && $depth == 0 // "CHAR" seems to be mistaken for a function by the parser
         ) {
             $retval[2] = strtoupper($parsed_param[$i]['data']);
         } else if ($parsed_param[$i]['type'] == 'punct_bracket_open_round' && $depth == 0) {
@@ -452,7 +427,7 @@ function PMA_RTN_getDataFromRequest()
     $retval['item_param_length']    = array();
     $retval['item_param_opts_num']  = array();
     $retval['item_param_opts_text'] = array();
-    if (isset($_REQUEST['item_param_name'])
+    if (   isset($_REQUEST['item_param_name'])
         && isset($_REQUEST['item_param_type'])
         && isset($_REQUEST['item_param_length'])
         && isset($_REQUEST['item_param_opts_num'])
@@ -464,65 +439,30 @@ function PMA_RTN_getDataFromRequest()
         && is_array($_REQUEST['item_param_opts_text'])
     ) {
         if ($_REQUEST['item_type'] == 'PROCEDURE') {
-            $temp_num_params = 0;
             $retval['item_param_dir'] = $_REQUEST['item_param_dir'];
             foreach ($retval['item_param_dir'] as $key => $value) {
                 if (! in_array($value, $param_directions, true)) {
                     $retval['item_param_dir'][$key] = '';
                 }
-                $retval['item_num_params']++;
-            }
-            if ($temp_num_params > $retval['item_num_params']) {
-                $retval['item_num_params'] = $temp_num_params;
             }
         }
-        $temp_num_params = 0;
         $retval['item_param_name'] = $_REQUEST['item_param_name'];
-        foreach ($retval['item_param_name'] as $key => $value) {
-            $retval['item_param_name'][$key] = $value;
-            $temp_num_params++;
-        }
-        if ($temp_num_params > $retval['item_num_params']) {
-            $retval['item_num_params'] = $temp_num_params;
-        }
-        $temp_num_params = 0;
         $retval['item_param_type'] = $_REQUEST['item_param_type'];
         foreach ($retval['item_param_type'] as $key => $value) {
             if (! in_array($value, PMA_getSupportedDatatypes(), true)) {
                 $retval['item_param_type'][$key] = '';
             }
-            $temp_num_params++;
-        }
-        if ($temp_num_params > $retval['item_num_params']) {
-            $retval['item_num_params'] = $temp_num_params;
-        }
-        $temp_num_params = 0;
-        $retval['item_param_length'] = $_REQUEST['item_param_length'];
-        foreach ($retval['item_param_length'] as $key => $value) {
-            $retval['item_param_length'][$key] = $value;
-            $temp_num_params++;
         }
-        if ($temp_num_params > $retval['item_num_params']) {
-            $retval['item_num_params'] = $temp_num_params;
-        }
-        $temp_num_params = 0;
-        $retval['item_param_opts_num'] = $_REQUEST['item_param_opts_num'];
-        foreach ($retval['item_param_opts_num'] as $key => $value) {
-            $retval['item_param_opts_num'][$key] = $value;
-            $temp_num_params++;
-        }
-        if ($temp_num_params > $retval['item_num_params']) {
-            $retval['item_num_params'] = $temp_num_params;
-        }
-        $temp_num_params = 0;
+        $retval['item_param_length']    = $_REQUEST['item_param_length'];
+        $retval['item_param_opts_num']  = $_REQUEST['item_param_opts_num'];
         $retval['item_param_opts_text'] = $_REQUEST['item_param_opts_text'];
-        foreach ($retval['item_param_opts_text'] as $key => $value) {
-            $retval['item_param_opts_text'][$key] = $value;
-            $temp_num_params++;
-        }
-        if ($temp_num_params > $retval['item_num_params']) {
-            $retval['item_num_params'] = $temp_num_params;
-        }
+        $retval['item_num_params'] = max(
+            count($retval['item_param_name']),
+            count($retval['item_param_type']),
+            count($retval['item_param_length']),
+            count($retval['item_param_opts_num']),
+            count($retval['item_param_opts_text'])
+        );
     }
     $retval['item_returntype'] = '';
     if (isset($_REQUEST['item_returntype'])
@@ -1032,7 +972,9 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine)
  */
 function PMA_RTN_getQueryFromRequest()
 {
-    global $_REQUEST, $cfg, $errors, $param_sqldataaccess, $param_opts_num;
+    global $_REQUEST, $cfg, $errors, $param_sqldataaccess, $param_opts_num, $param_directions;
+
+    $_REQUEST['item_type'] = isset($_REQUEST['item_type']) ? $_REQUEST['item_type'] : '';
 
     $query = 'CREATE ';
     if (! empty($_REQUEST['item_definer'])) {
@@ -1052,7 +994,7 @@ function PMA_RTN_getQueryFromRequest()
         $errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_type']));
     }
     if (! empty($_REQUEST['item_name'])) {
-        $query .= PMA_backquote($_REQUEST['item_name']) . ' ';
+        $query .= PMA_backquote($_REQUEST['item_name']);
     } else {
         $errors[] = __('You must provide a routine name');
     }
@@ -1069,7 +1011,10 @@ function PMA_RTN_getQueryFromRequest()
     ) {
         for ($i=0; $i<count($_REQUEST['item_param_name']); $i++) {
             if (! empty($_REQUEST['item_param_name'][$i]) && ! empty($_REQUEST['item_param_type'][$i])) {
-                if ($_REQUEST['item_type'] == 'PROCEDURE' && ! empty($_REQUEST['item_param_dir'][$i])) {
+                if ($_REQUEST['item_type'] == 'PROCEDURE'
+                    && ! empty($_REQUEST['item_param_dir'][$i])
+                    && in_array($_REQUEST['item_param_dir'][$i], $param_directions)
+                ) {
                     $params .= $_REQUEST['item_param_dir'][$i] . " " . PMA_backquote($_REQUEST['item_param_name'][$i]) . " "
                             . $_REQUEST['item_param_type'][$i];
                 } else if ($_REQUEST['item_type'] == 'FUNCTION') {
@@ -1093,19 +1038,13 @@ function PMA_RTN_getQueryFromRequest()
                     }
                 }
                 if (! empty($_REQUEST['item_param_opts_text'][$i])) {
-                    if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])])) {
-                        $group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])];
-                        if ($group == 'FUNC_CHAR') {
-                            $params .= ' CHARSET ' . strtolower($_REQUEST['item_param_opts_text'][$i]);
-                        }
+                    if (in_array($_REQUEST['item_param_type'][$i], $cfg['ColumnTypes']['STRING'])) {
+                        $params .= ' CHARSET ' . strtolower($_REQUEST['item_param_opts_text'][$i]);
                     }
                 }
                 if (! empty($_REQUEST['item_param_opts_num'][$i])) {
-                    if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])])) {
-                        $group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_param_type'][$i])];
-                        if ($group == 'FUNC_NUMBER' && in_array($_REQUEST['item_param_opts_num'][$i], $param_opts_num)) {
-                            $params .= ' ' . strtoupper($_REQUEST['item_param_opts_num'][$i]);
-                        }
+                    if (in_array($_REQUEST['item_param_type'][$i], $cfg['ColumnTypes']['NUMERIC'])) {
+                        $params .= ' ' . strtoupper($_REQUEST['item_param_opts_num'][$i]);
                     }
                 }
                 if ($i != count($_REQUEST['item_param_name'])-1) {
@@ -1118,7 +1057,7 @@ function PMA_RTN_getQueryFromRequest()
             }
         }
     }
-    $query .= " (" . $params . ") ";
+    $query .= "(" . $params . ") ";
     if ($_REQUEST['item_type'] == 'FUNCTION') {
         if (! empty($_REQUEST['item_returntype']) && in_array($_REQUEST['item_returntype'], PMA_getSupportedDatatypes())) {
             $query .= "RETURNS {$_REQUEST['item_returntype']}";
@@ -1137,19 +1076,13 @@ function PMA_RTN_getQueryFromRequest()
             }
         }
         if (! empty($_REQUEST['item_returnopts_text'])) {
-            if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])])) {
-                $group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])];
-                if ($group == 'FUNC_CHAR') {
-                    $query .= ' CHARSET ' . strtolower($_REQUEST['item_returnopts_text']);
-                }
+            if (in_array($_REQUEST['item_returntype'], $cfg['ColumnTypes']['STRING'])) {
+                $query .= ' CHARSET ' . strtolower($_REQUEST['item_returnopts_text']);
             }
         }
         if (! empty($_REQUEST['item_returnopts_num'])) {
-            if (isset($cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])])) {
-                $group = $cfg['RestrictColumnTypes'][strtoupper($_REQUEST['item_returntype'])];
-                if ($group == 'FUNC_NUMBER' && in_array($_REQUEST['item_returnopts_num'], $param_opts_num)) {
-                    $query .= ' ' . strtoupper($_REQUEST['item_returnopts_num']);
-                }
+            if (in_array($_REQUEST['item_returntype'], $cfg['ColumnTypes']['NUMERIC'])) {
+                $query .= ' ' . strtoupper($_REQUEST['item_returnopts_num']);
             }
         }
         $query .= ' ';
diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php
index 66aebcf..8c65a67 100644
--- a/libraries/rte/rte_triggers.lib.php
+++ b/libraries/rte/rte_triggers.lib.php
@@ -25,33 +25,9 @@ function PMA_TRI_setGlobals()
 }
 
 /**
- * This function is defined in: rte_routines.lib.php, rte_triggers.lib.php and
- * rte_events.lib.php. It is used to retreive some language strings that are
- * used in functionalities that are common to routines, triggers and events.
- *
- * @param   string  $index   The index of the string to get
- *
- * @return  string  The requested string or an empty string, if not available
- */
-function PMA_RTE_getWord($index)
-{
-    $words = array(
-        'add'       => __('Add trigger'),
-        'docu'      => 'TRIGGERS',
-        'export'    => __('Export of trigger %s'),
-        'human'     => __('trigger'),
-        'no_create' => __('You do not have the necessary privileges to create a trigger'),
-        'not_found' => __('No trigger with name %1$s found in database %2$s'),
-        'nothing'   => __('There are no triggers to display.'),
-        'title'     => __('Triggers'),
-    );
-    return isset($words[$index]) ? $words[$index] : '';
-} // end PMA_RTE_getWord()
-
-/**
  * Main function for the triggers functionality
  */
-function PMA_RTE_main()
+function PMA_TRI_main()
 {
     global $db, $table;
 
@@ -71,7 +47,7 @@ function PMA_RTE_main()
      * if the user has the necessary privileges
      */
     echo PMA_TRI_getFooterLinks();
-} // end PMA_RTE_main()
+} // end PMA_TRI_main()
 
 /**
  * Handles editor requests for adding or editing an item
diff --git a/libraries/rte/rte_words.lib.php b/libraries/rte/rte_words.lib.php
new file mode 100644
index 0000000..6e7836a
--- /dev/null
+++ b/libraries/rte/rte_words.lib.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * This function is used to retreive some language strings that are used
+ * in functionalities that are common to routines, triggers and events.
+ *
+ * @param   string  $index   The index of the string to get
+ *
+ * @return  string  The requested string or an empty string, if not available
+ */
+function PMA_RTE_getWord($index)
+{
+	global $_PMA_RTE;
+
+	switch ($_PMA_RTE) {
+	case 'RTN':
+		$words = array(
+		    'add'       => __('Add routine'),
+		    'docu'      => 'STORED_ROUTINES',
+		    'export'    => __('Export of routine %s'),
+		    'human'     => __('routine'),
+		    'no_create' => __('You do not have the necessary privileges to create a routine'),
+		    'not_found' => __('No routine with name %1$s found in database %2$s'),
+		    'nothing'   => __('There are no routines to display.'),
+		    'title'     => __('Routines'),
+		);
+		break;
+	case 'TRI':
+		$words = array(
+		    'add'       => __('Add trigger'),
+		    'docu'      => 'TRIGGERS',
+		    'export'    => __('Export of trigger %s'),
+		    'human'     => __('trigger'),
+		    'no_create' => __('You do not have the necessary privileges to create a trigger'),
+		    'not_found' => __('No trigger with name %1$s found in database %2$s'),
+		    'nothing'   => __('There are no triggers to display.'),
+		    'title'     => __('Triggers'),
+		);
+		break;
+	case 'EVN':
+		$words = array(
+		    'add'       => __('Add event'),
+		    'docu'      => 'EVENTS',
+		    'export'    => __('Export of event %s'),
+		    'human'     => __('event'),
+		    'no_create' => __('You do not have the necessary privileges to create an event'),
+		    'not_found' => __('No event with name %1$s found in database %2$s'),
+		    'nothing'   => __('There are no events to display.'),
+		    'title'     => __('Events'),
+		);
+		break;
+	default:
+		$words = array();
+		break;
+	}
+
+    return isset($words[$index]) ? $words[$index] : '';
+} // end PMA_RTE_getWord()
+
+?>


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list