diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php
index b0b6358242..b69c4bb4c3 100644
--- a/libraries/rte/rte_routines.lib.php
+++ b/libraries/rte/rte_routines.lib.php
@@ -114,7 +114,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') && $depth == 0 // "CHAR" seems to be mistaken for a function by the parser
+ || $parsed_param[$i]['type'] == 'alpha_functionName') && $depth == 0
) {
$retval[2] = strtoupper($parsed_param[$i]['data']);
} else if ($parsed_param[$i]['type'] == 'punct_bracket_open_round'
@@ -277,11 +277,19 @@ function PMA_RTN_handleEditor()
// Execute the created query
if (! empty($_REQUEST['editor_process_edit'])) {
if (! in_array($_REQUEST['item_original_type'], array('PROCEDURE', 'FUNCTION'))) {
- $errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_original_type']));
+ $errors[] = sprintf(
+ __('Invalid routine type: "%s"'),
+ htmlspecialchars($_REQUEST['item_original_type'])
+ );
} else {
// Backup the old routine, in case something goes wrong
- $create_routine = PMA_DBI_get_definition($db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name']);
- $drop_routine = "DROP {$_REQUEST['item_original_type']} " . PMA_Util::backquote($_REQUEST['item_original_name']) . ";\n";
+ $create_routine = PMA_DBI_get_definition(
+ $db, $_REQUEST['item_original_type'],
+ $_REQUEST['item_original_name']
+ );
+ $drop_routine = "DROP {$_REQUEST['item_original_type']} "
+ . PMA_Util::backquote($_REQUEST['item_original_name'])
+ . ";\n";
$result = PMA_DBI_try_query($drop_routine);
if (! $result) {
$errors[] = sprintf(
@@ -299,7 +307,8 @@ function PMA_RTN_handleEditor()
)
. ' '
. __('MySQL said: ') . PMA_DBI_getError(null);
- // We dropped the old routine, but were unable to create the new one
+ // We dropped the old routine,
+ // but were unable to create the new one
// Try to restore the backup query
$result = PMA_DBI_try_query($create_routine);
if (! $result) {
@@ -309,7 +318,8 @@ function PMA_RTN_handleEditor()
// This should not happen, but we better handle
// this just in case.
$errors[] = __(
- 'Sorry, we failed to restore the dropped routine.'
+ 'Sorry, we failed to restore'
+ . ' the dropped routine.'
)
. ' '
. __('The backed up query was:')
@@ -352,7 +362,10 @@ function PMA_RTN_handleEditor()
if (count($errors)) {
$message = PMA_Message::error(
- __('One or more errors have occured while processing your request:')
+ __(
+ 'One or more errors have occured while'
+ . ' processing your request:'
+ )
);
$message->addString('
');
foreach ($errors as $string) {
@@ -365,12 +378,20 @@ function PMA_RTN_handleEditor()
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
if ($message->isSuccess()) {
- $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
+ $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`,"
+ . " `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
$where = "ROUTINE_SCHEMA='" . PMA_Util::sqlAddSlashes($db) . "' "
- . "AND ROUTINE_NAME='" . PMA_Util::sqlAddSlashes($_REQUEST['item_name']) . "'"
- . "AND ROUTINE_TYPE='" . PMA_Util::sqlAddSlashes($_REQUEST['item_type']) . "'";
- $routine = PMA_DBI_fetch_single_row("SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;");
- $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name'])));
+ . "AND ROUTINE_NAME='"
+ . PMA_Util::sqlAddSlashes($_REQUEST['item_name']) . "'"
+ . "AND ROUTINE_TYPE='"
+ . PMA_Util::sqlAddSlashes($_REQUEST['item_type']) . "'";
+ $routine = PMA_DBI_fetch_single_row(
+ "SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES`"
+ . " WHERE $where;"
+ );
+ $response->addJSON(
+ 'name', htmlspecialchars(strtoupper($_REQUEST['item_name']))
+ );
$response->addJSON('new_row', PMA_RTN_getRowForList($routine));
$response->addJSON('insert', ! empty($routine));
$response->addJSON('message', $output);
@@ -385,10 +406,14 @@ function PMA_RTN_handleEditor()
/**
* Display a form used to add/edit a routine, if necessary
*/
- if (count($errors) || ( empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit'])
+ // FIXME: this must be simpler than that
+ if (count($errors)
+ || ( empty($_REQUEST['editor_process_add'])
+ && empty($_REQUEST['editor_process_edit'])
&& (! empty($_REQUEST['add_item']) || ! empty($_REQUEST['edit_item'])
- || ! empty($_REQUEST['routine_addparameter']) || ! empty($_REQUEST['routine_removeparameter'])
- || ! empty($_REQUEST['routine_changetype']))) // FIXME: this must be simpler than that
+ || ! empty($_REQUEST['routine_addparameter'])
+ || ! empty($_REQUEST['routine_removeparameter'])
+ || ! empty($_REQUEST['routine_changetype'])))
) {
// Handle requests to add/remove parameters and changing routine type
// This is necessary when JS is disabled
@@ -407,8 +432,12 @@ function PMA_RTN_handleEditor()
$mode = 'add';
} else if (! empty($_REQUEST['edit_item'])) {
$title = __("Edit routine");
- if (! $operation && ! empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit'])) {
- $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type']);
+ if (! $operation && ! empty($_REQUEST['item_name'])
+ && empty($_REQUEST['editor_process_edit'])
+ ) {
+ $routine = PMA_RTN_getDataFromName(
+ $_REQUEST['item_name'], $_REQUEST['item_type']
+ );
if ($routine !== false) {
$routine['item_original_name'] = $routine['item_name'];
$routine['item_original_type'] = $routine['item_type'];
@@ -744,20 +773,22 @@ function PMA_RTN_getParameterRow($routine = array(), $index = null, $class = '')
}
$retval .= " \n";
$retval .= " \n";
- $retval .= "