cdbt
cdbt copied to clipboard
Create Table SQL is invalid
Using release v 1.10 I cannot create tables with the front-end plugin. It generates a popup saying “Create Table SQL is invalid.”
In method validate_create_sql from file lib/cdbt.class.php:
$org_sql = preg_replace("/\r|\n|\t/", '', $sql);
$reg_base = '/^(CREATE\sTABLE\s'. $table_name .'\s()(.*)$/iU';
The preg_replace call removes spacing characters if they are newlines. This causes the first preg_match to fail unnecessarily sometimes.
I’m currently using $org_sql = trim(preg_replace("/[\s|\r|\n|\t]+/", ' ', $sql)); instead to turn any run of these characters into a single normal space character and then remove any preceding whitespace characters.
I also use $reg_base = '/^(CREATE\sTABLE\s'. $table_name .'\s_()(._)$/iU'; because space between table name and opening parenthesis is not required in SQL.
It allows me to proceed, but am I using the right approach? Could doing this break something else?
validate_alter_sql has similar.
Tried to fix the SQL validation process. During the current operation test