From 1db0f95b1b6ccf090583b50d686fbff086af56ef Mon Sep 17 00:00:00 2001 From: Thomas Faller Date: Sun, 18 Sep 2016 03:36:34 +0200 Subject: [PATCH 1/2] Fix error check of a routine execution Signed-off-by: Thomas Faller --- libraries/rte/rte_routines.lib.php | 52 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index 6c6e5c949f..98a92c8edb 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -1416,37 +1416,41 @@ function PMA_RTN_handleExecute() $GLOBALS['dbi']->freeResult($result); - } while ($GLOBALS['dbi']->nextResult()); + } while ($outcome = $GLOBALS['dbi']->nextResult()); - $output .= ""; + if ($outcome) { + $output .= ""; - $message = __('Your SQL query has been executed successfully.'); - if ($routine['item_type'] == 'PROCEDURE') { - $message .= '
'; + $message = __('Your SQL query has been executed successfully.'); + if ($routine['item_type'] == 'PROCEDURE') { + $message .= '
'; - // TODO : message need to be modified according to the - // output from the routine - $message .= sprintf( - _ngettext( - '%d row affected by the last statement inside the ' - . 'procedure.', - '%d rows affected by the last statement inside the ' - . 'procedure.', + // TODO : message need to be modified according to the + // output from the routine + $message .= sprintf( + _ngettext( + '%d row affected by the last statement inside the ' + . 'procedure.', + '%d rows affected by the last statement inside the ' + . 'procedure.', + $affected + ), $affected - ), - $affected - ); - } - $message = Message::success($message); + ); + } + $message = Message::success($message); - if ($nbResultsetToDisplay == 0) { - $notice = __( - 'MySQL returned an empty result set (i.e. zero rows).' - ); - $output .= Message::notice($notice)->getDisplay(); + if ($nbResultsetToDisplay == 0) { + $notice = __( + 'MySQL returned an empty result set (i.e. zero rows).' + ); + $output .= Message::notice($notice)->getDisplay(); + } } - } else { + } + + if (! $outcome) { $output = ''; $message = Message::error( sprintf( From 037bddd7c3560c1f0e81730d815302f67f98d5bc Mon Sep 17 00:00:00 2001 From: Thomas Faller Date: Sun, 18 Sep 2016 12:26:37 +0200 Subject: [PATCH 2/2] Removed trailing space, simplified error check. Signed-off-by: Thomas Faller --- libraries/rte/rte_routines.lib.php | 53 +++++++++++++++--------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index 98a92c8edb..5f9e7a5c68 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -1417,40 +1417,39 @@ function PMA_RTN_handleExecute() $GLOBALS['dbi']->freeResult($result); } while ($outcome = $GLOBALS['dbi']->nextResult()); + } - if ($outcome) { - $output .= ""; + if ($outcome) { - $message = __('Your SQL query has been executed successfully.'); - if ($routine['item_type'] == 'PROCEDURE') { - $message .= '
'; + $output .= ""; - // TODO : message need to be modified according to the - // output from the routine - $message .= sprintf( - _ngettext( - '%d row affected by the last statement inside the ' - . 'procedure.', - '%d rows affected by the last statement inside the ' - . 'procedure.', - $affected - ), + $message = __('Your SQL query has been executed successfully.'); + if ($routine['item_type'] == 'PROCEDURE') { + $message .= '
'; + + // TODO : message need to be modified according to the + // output from the routine + $message .= sprintf( + _ngettext( + '%d row affected by the last statement inside the ' + . 'procedure.', + '%d rows affected by the last statement inside the ' + . 'procedure.', $affected - ); - } - $message = Message::success($message); + ), + $affected + ); + } + $message = Message::success($message); - if ($nbResultsetToDisplay == 0) { - $notice = __( - 'MySQL returned an empty result set (i.e. zero rows).' - ); - $output .= Message::notice($notice)->getDisplay(); - } + if ($nbResultsetToDisplay == 0) { + $notice = __( + 'MySQL returned an empty result set (i.e. zero rows).' + ); + $output .= Message::notice($notice)->getDisplay(); } - } - - if (! $outcome) { + } else { $output = ''; $message = Message::error( sprintf(