diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php
index 11d839a9c5..12ce2fbece 100644
--- a/libraries/rte/rte_routines.lib.php
+++ b/libraries/rte/rte_routines.lib.php
@@ -276,7 +276,11 @@ function PMA_RTN_handleEditor()
if (! count($errors)) { // set by PMA_RTN_getQueryFromRequest()
// Execute the created query
if (! empty($_REQUEST['editor_process_edit'])) {
- if (! in_array($_REQUEST['item_original_type'], array('PROCEDURE', 'FUNCTION'))) {
+ $isProcOrFunc = in_array(
+ $_REQUEST['item_original_type'],
+ array('PROCEDURE', 'FUNCTION')
+ );
+ if (!$isProcOrFunc) {
$errors[] = sprintf(
__('Invalid routine type: "%s"'),
htmlspecialchars($_REQUEST['item_original_type'])
@@ -325,7 +329,8 @@ function PMA_RTN_handleEditor()
. __('The backed up query was:')
. "\"" . htmlspecialchars($create_routine) . "\""
. '
'
- . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
+ . __('MySQL said: ')
+ . $GLOBALS['dbi']->getError(null);
}
} else {
$message = PMA_Message::success(
@@ -1094,7 +1099,7 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine)
*/
function PMA_RTN_getQueryFromRequest()
{
- global $_REQUEST, $errors, $param_sqldataaccess, $param_directions;
+ global $_REQUEST, $errors, $param_sqldataaccess, $param_directions, $PMA_Types;
$_REQUEST['item_type'] = isset($_REQUEST['item_type'])
? $_REQUEST['item_type'] : '';
@@ -1128,6 +1133,7 @@ function PMA_RTN_getQueryFromRequest()
$warned_about_dir = false;
$warned_about_name = false;
$warned_about_length = false;
+
if ( ! empty($_REQUEST['item_param_name'])
&& ! empty($_REQUEST['item_param_type'])
&& ! empty($_REQUEST['item_param_length'])
@@ -1135,20 +1141,24 @@ function PMA_RTN_getQueryFromRequest()
&& is_array($_REQUEST['item_param_type'])
&& is_array($_REQUEST['item_param_length'])
) {
- for ($i=0; $igetTypeClass($_REQUEST['item_param_type'][$i]) == 'CHAR') {
+ if ($PMA_Types->getTypeClass($item_param_type[$i]) == 'CHAR') {
$params .= ' CHARSET '
. strtolower($_REQUEST['item_param_opts_text'][$i]);
}
}
if (! empty($_REQUEST['item_param_opts_num'][$i])) {
- if ($GLOBALS['PMA_Types']->getTypeClass($_REQUEST['item_param_type'][$i]) == 'NUMBER') {
+ if ($PMA_Types->getTypeClass($item_param_type[$i]) == 'NUMBER') {
$params .= ' '
. strtoupper($_REQUEST['item_param_opts_num'][$i]);
}
}
- if ($i != count($_REQUEST['item_param_name'])-1) {
+ if ($i != (count($item_param_name) - 1)) {
$params .= ", ";
}
} else if (! $warned_about_name) {
@@ -1203,25 +1215,28 @@ function PMA_RTN_getQueryFromRequest()
}
$query .= "(" . $params . ") ";
if ($_REQUEST['item_type'] == 'FUNCTION') {
- if (! empty($_REQUEST['item_returntype'])
+ $item_returntype = $_REQUEST['item_returntype'];
+
+ if (! empty($item_returntype)
&& in_array(
- $_REQUEST['item_returntype'], PMA_Util::getSupportedDatatypes()
+ $item_returntype, PMA_Util::getSupportedDatatypes()
)
) {
- $query .= "RETURNS {$_REQUEST['item_returntype']}";
+ $query .= "RETURNS " . $item_returntype;
} else {
$errors[] = __('You must provide a valid return type for the routine.');
}
if (! empty($_REQUEST['item_returnlength'])
&& !preg_match(
- '@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN)$@i',
- $_REQUEST['item_returntype']
+ '@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|'
+ . 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN)$@i',
+ $item_returntype
)
) {
$query .= "(" . $_REQUEST['item_returnlength'] . ")";
} else if (empty($_REQUEST['item_returnlength'])
&& preg_match(
- '@^(ENUM|SET|VARCHAR|VARBINARY)$@i', $_REQUEST['item_returntype']
+ '@^(ENUM|SET|VARCHAR|VARBINARY)$@i', $item_returntype
)
) {
if (! $warned_about_length) {
@@ -1233,13 +1248,13 @@ function PMA_RTN_getQueryFromRequest()
}
}
if (! empty($_REQUEST['item_returnopts_text'])) {
- if ($GLOBALS['PMA_Types']->getTypeClass($_REQUEST['item_returntype']) == 'CHAR') {
+ if ($PMA_Types->getTypeClass($item_returntype) == 'CHAR') {
$query .= ' CHARSET '
. strtolower($_REQUEST['item_returnopts_text']);
}
}
if (! empty($_REQUEST['item_returnopts_num'])) {
- if ($GLOBALS['PMA_Types']->getTypeClass($_REQUEST['item_returntype']) == 'NUMBER') {
+ if ($PMA_Types->getTypeClass($item_returntype) == 'NUMBER') {
$query .= ' ' . strtoupper($_REQUEST['item_returnopts_num']);
}
}
@@ -1382,7 +1397,8 @@ function PMA_RTN_handleExecute()
if (($result !== false) && ($num_rows > 0)) {
$output .= "