From 91c6a2ad081d61a807278272ee2a0ee513641813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 16 Dec 2015 09:15:22 +0100 Subject: [PATCH 1/5] Fix possible undefined variable in case of error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- tbl_operations.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tbl_operations.php b/tbl_operations.php index a0aaa7275d..1c70bffa33 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -243,7 +243,9 @@ if (isset($result) && empty($message_to_show)) { $_message = new PMA\libraries\Message; $_message->addMessages($warning_messages); $_message->isError(true); - if ($GLOBALS['ajax_request'] == true) { + if (isset($GLOBALS['ajax_request']) + && $GLOBALS['ajax_request'] == true + ) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(false); $response->addJSON('message', $_message); From 8fc0dc7032b4f71967738beabaa23ff97dc5b91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 16 Dec 2015 09:24:02 +0100 Subject: [PATCH 2/5] Include SQL even in case of error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- tbl_operations.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tbl_operations.php b/tbl_operations.php index 1c70bffa33..6cf91707a7 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -249,6 +249,9 @@ if (isset($result) && empty($message_to_show)) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(false); $response->addJSON('message', $_message); + $response->addJSON( + 'sql_query', PMA\libraries\Util::getMessage(null, $sql_query) + ); exit; } unset($warning_messages); From c217eaffc27f4d3a81e52f2f13eff98ff6dbd9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 16 Dec 2015 09:27:40 +0100 Subject: [PATCH 3/5] Use default messages, no need to duplicate them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- tbl_operations.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tbl_operations.php b/tbl_operations.php index 6cf91707a7..305fd2e53e 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -220,10 +220,8 @@ if (isset($result) && empty($message_to_show)) { $_type = 'success'; if (empty($_message)) { $_message = $result - ? PMA\libraries\Message::success( - __('Your SQL query has been executed successfully.') - ) - : PMA\libraries\Message::error(__('Error')); + ? PMA\libraries\Message::success() + : PMA\libraries\Message::error(); // $result should exist, regardless of $_message $_type = $result ? 'success' : 'error'; From a2a321eaf798af93d48951960d60588224e76145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 16 Dec 2015 09:37:54 +0100 Subject: [PATCH 4/5] No need to set type of message when we pass Message instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- tbl_operations.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tbl_operations.php b/tbl_operations.php index 305fd2e53e..66e36392c9 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -215,15 +215,10 @@ if ($reread_info) { unset($reread_info); if (isset($result) && empty($message_to_show)) { - // set to success by default, because result set could be empty - // (for example, a table rename) - $_type = 'success'; if (empty($_message)) { $_message = $result ? PMA\libraries\Message::success() : PMA\libraries\Message::error(); - // $result should exist, regardless of $_message - $_type = $result ? 'success' : 'error'; if (isset($GLOBALS['ajax_request']) && $GLOBALS['ajax_request'] == true @@ -256,9 +251,9 @@ if (isset($result) && empty($message_to_show)) { } $response->addHTML( - PMA\libraries\Util::getMessage($_message, $sql_query, $_type) + PMA\libraries\Util::getMessage($_message, $sql_query) ); - unset($_message, $_type); + unset($_message); } $url_params['goto'] From 2076b0203beff2dd23bff14b2654c901a8bf2126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 16 Dec 2015 09:43:11 +0100 Subject: [PATCH 5/5] Fixed displaying of SQL query on table operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - do not show message about executed SQL when none was executed - always show the SQL Signed-off-by: Michal Čihař --- ChangeLog | 1 + tbl_operations.php | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff658eba51..27e1239292 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ phpMyAdmin - ChangeLog + issue #11711 Clarify the meaning of "Stand-in structure for view" in SQL export - issue HTML line break shown after a MySQL connection error message - issue #11728 CSV import skip row count after +- issue Fixed displaying of SQL query on table operations 4.5.3.0 (not yet released) - issue #11664 Online syntax verifier bug - "IF" on SELECT statement diff --git a/tbl_operations.php b/tbl_operations.php index 66e36392c9..3dcd5b534c 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -197,8 +197,6 @@ if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) { /** * A partition operation has been requested by the user */ -$sql_query = ''; - if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation']) ) { @@ -216,9 +214,13 @@ unset($reread_info); if (isset($result) && empty($message_to_show)) { if (empty($_message)) { - $_message = $result - ? PMA\libraries\Message::success() - : PMA\libraries\Message::error(); + if (empty($sql_query)) { + $_message = PMA\libraries\Message::success(__('No change')); + } else { + $_message = $result + ? PMA\libraries\Message::success() + : PMA\libraries\Message::error(); + } if (isset($GLOBALS['ajax_request']) && $GLOBALS['ajax_request'] == true @@ -226,9 +228,11 @@ if (isset($result) && empty($message_to_show)) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus($_message->isSuccess()); $response->addJSON('message', $_message); - $response->addJSON( - 'sql_query', PMA\libraries\Util::getMessage(null, $sql_query) - ); + if (!empty($sql_query)) { + $response->addJSON( + 'sql_query', PMA\libraries\Util::getMessage(null, $sql_query) + ); + } exit; } } @@ -242,17 +246,25 @@ if (isset($result) && empty($message_to_show)) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(false); $response->addJSON('message', $_message); - $response->addJSON( - 'sql_query', PMA\libraries\Util::getMessage(null, $sql_query) - ); + if (!empty($sql_query)) { + $response->addJSON( + 'sql_query', PMA\libraries\Util::getMessage(null, $sql_query) + ); + } exit; } unset($warning_messages); } - $response->addHTML( - PMA\libraries\Util::getMessage($_message, $sql_query) - ); + if (empty($sql_query)) { + $response->addHTML( + $_message->getDisplay() + ); + } else { + $response->addHTML( + PMA\libraries\Util::getMessage($_message, $sql_query) + ); + } unset($_message); }