From 1db0f95b1b6ccf090583b50d686fbff086af56ef Mon Sep 17 00:00:00 2001 From: Thomas Faller Date: Sun, 18 Sep 2016 03:36:34 +0200 Subject: [PATCH] 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(