From 820247dbd69b49d1704e7d93951e65c144cb75e3 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 21 Mar 2024 15:54:29 +0100 Subject: [PATCH] Fix condition in createDictionary for modulebuilder --- htdocs/core/lib/modulebuilder.lib.php | 6 ++---- htdocs/modulebuilder/index.php | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 0250110d229..200b3422d3a 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -1288,7 +1288,7 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul } $columns = array( - 'rowid' => array('type' => 'integer', 'value' => 11, 'extra' => 'AUTO_INCREMENT PRIMARY KEY'), + 'rowid' => array('type' => 'integer', 'value' => 11, 'extra' => 'AUTO_INCREMENT'), 'code' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), 'label' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), 'position' => array('type' => 'integer', 'value' => 11, 'null'=>'NULL'), @@ -1310,9 +1310,7 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul } // check if tablename exist in Database and create it if not - // @FIXME We must use $db->DDLDescTable($table) to know if a table exists. - $query = "SHOW TABLES LIKE '" . $db->escape(MAIN_DB_PREFIX.strtolower($namedic)) . "'"; - $checkTable = $db->query($query); + $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($namedic)); if ($checkTable && $db->num_rows($checkTable) > 0) { setEventMessages($langs->trans("ErrorTableExist", $namedic), null, 'errors'); return; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 3c0d1e41776..d7148121d4b 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2102,8 +2102,7 @@ if (($dirins && $action == 'confirm_deletedictionary' && $dicname) || ($dirins & } //chercher la table dicname - $query = "SHOW TABLES LIKE '" . MAIN_DB_PREFIX.strtolower($newdicname) . "'"; - $checkTable = $db->query($query); + $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname)); if ($checkTable && $db->num_rows($checkTable) <= 0) { $error++; }