diff options
author | William Desportes <williamdes@wdes.fr> | 2021-03-11 22:58:20 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2021-03-11 23:09:46 +0300 |
commit | c71c11e7872d0acf4c7477fbdbd567da1ee8e253 (patch) | |
tree | 4e42274a03a2d43d5fdb2c9dcb382f117bb74b85 /libraries/classes/CreateAddField.php | |
parent | 0673bd81406c72a235998321cd8b25ec4f7e51a6 (diff) |
Remove an exit by moving out the preview SQL code on table create add field
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'libraries/classes/CreateAddField.php')
-rw-r--r-- | libraries/classes/CreateAddField.php | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/libraries/classes/CreateAddField.php b/libraries/classes/CreateAddField.php index 4d378ee9d8..ac8f413cbc 100644 --- a/libraries/classes/CreateAddField.php +++ b/libraries/classes/CreateAddField.php @@ -525,22 +525,39 @@ class CreateAddField } /** + * Function to get the column creation statement + * + * @param string $table current table + */ + public function getColumnCreationQuery( + string $table + ): string { + // get column addition statements + $sqlStatement = $this->getColumnCreationStatements(false); + + $sqlQuery = 'ALTER TABLE ' . + Util::backquote($table) . ' ' . $sqlStatement; + if (isset($_POST['online_transaction'])) { + $sqlQuery .= ', ALGORITHM=INPLACE, LOCK=NONE'; + } + + return $sqlQuery . ';'; + } + + /** * Function to execute the column creation statement * * @param string $db current database - * @param string $table current table + * @param string $sqlQuery the query to run * @param string $errorUrl error page url * * @return array */ public function tryColumnCreationQuery( string $db, - string $table, + string $sqlQuery, string $errorUrl ): array { - // get column addition statements - $sqlStatement = $this->getColumnCreationStatements(false); - // To allow replication, we first select the db to use and then run queries // on this db. if (! $this->dbi->selectDb($db)) { @@ -552,21 +569,6 @@ class CreateAddField ); } - $sqlQuery = 'ALTER TABLE ' . - Util::backquote($table) . ' ' . $sqlStatement; - if (isset($_POST['online_transaction'])) { - $sqlQuery .= ', ALGORITHM=INPLACE, LOCK=NONE'; - } - - $sqlQuery .= ';'; - - // If there is a request for SQL previewing. - if (isset($_POST['preview_sql'])) { - Core::previewSQL($sqlQuery); - - exit; - } - return [ $this->dbi->tryQuery($sqlQuery), $sqlQuery, |