From ea806f645d98fa87ec4b8a1d644c3d5216abf211 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 8 Nov 2015 15:22:54 +0100 Subject: [PATCH] Reduce nested levels. Signed-off-by: Hugues Peccatte --- libraries/pmd_common.php | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/libraries/pmd_common.php b/libraries/pmd_common.php index 853f1de31f..e7fb5595a3 100644 --- a/libraries/pmd_common.php +++ b/libraries/pmd_common.php @@ -452,26 +452,30 @@ function PMA_saveTablePositions($pg) $res = PMA_queryAsControlUser($query, true, PMA\libraries\DatabaseInterface::QUERY_STORE); - if ($res) { - foreach ($_REQUEST['t_h'] as $key => $value) { - list($DB, $TAB) = explode(".", $key); - if ($value) { - $query = "INSERT INTO " - . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "." - . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['table_coords']) - . " (`db_name`, `table_name`, `pdf_page_number`, `x`, `y`)" - . " VALUES (" - . "'" . PMA\libraries\Util::sqlAddSlashes($DB) . "', " - . "'" . PMA\libraries\Util::sqlAddSlashes($TAB) . "', " - . "'" . PMA\libraries\Util::sqlAddSlashes($pg) . "', " - . "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['t_x'][$key]) . "', " - . "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['t_y'][$key]) . "')"; + if (!$res) { + return (boolean)$res; + } - $res = PMA_queryAsControlUser( - $query, true, PMA\libraries\DatabaseInterface::QUERY_STORE - ); - } + foreach ($_REQUEST['t_h'] as $key => $value) { + list($DB, $TAB) = explode(".", $key); + if (!$value) { + continue; } + + $query = "INSERT INTO " + . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "." + . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['table_coords']) + . " (`db_name`, `table_name`, `pdf_page_number`, `x`, `y`)" + . " VALUES (" + . "'" . PMA\libraries\Util::sqlAddSlashes($DB) . "', " + . "'" . PMA\libraries\Util::sqlAddSlashes($TAB) . "', " + . "'" . PMA\libraries\Util::sqlAddSlashes($pg) . "', " + . "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['t_x'][$key]) . "', " + . "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['t_y'][$key]) . "')"; + + $res = PMA_queryAsControlUser( + $query, true, PMA\libraries\DatabaseInterface::QUERY_STORE + ); } return (boolean) $res;