Debug v18 - warnings and pgsql migration

This commit is contained in:
Laurent Destailleur
2023-06-26 23:02:17 +02:00
parent 73bcc9c261
commit b6a061f795
8 changed files with 38 additions and 19 deletions

View File

@@ -152,20 +152,21 @@ function versiondolibarrarray()
* Install process however does not use it.
* Note that Sql files must have all comments at start of line. Also this function take ';' as the char to detect end of sql request
*
* @param string $sqlfile Full path to sql file
* @param int $silent 1=Do not output anything, 0=Output line for update page
* @param int $entity Entity targeted for multicompany module
* @param int $usesavepoint 1=Run a savepoint before each request and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
* @param string $handler Handler targeted for menu (replace __HANDLER__ with this value)
* @param string $okerror Family of errors we accept ('default', 'none')
* @param int $linelengthlimit Limit for length of each line (Use 0 if unknown, may be faster if defined)
* @param int $nocommentremoval Do no try to remove comments (in such a case, we consider that each line is a request, so use also $linelengthlimit=0)
* @param int $offsetforchartofaccount Offset to use to load chart of account table to update sql on the fly to add offset to rowid and account_parent value
* @param int $colspan 2=Add a colspan=2 on td
* @param int $onlysqltoimportwebsite Only sql resquests used to import a website template are allowed
* @return int <=0 if KO, >0 if OK
* @param string $sqlfile Full path to sql file
* @param int $silent 1=Do not output anything, 0=Output line for update page
* @param int $entity Entity targeted for multicompany module
* @param int $usesavepoint 1=Run a savepoint before each request and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
* @param string $handler Handler targeted for menu (replace __HANDLER__ with this value)
* @param string $okerror Family of errors we accept ('default', 'none')
* @param int $linelengthlimit Limit for length of each line (Use 0 if unknown, may be faster if defined)
* @param int $nocommentremoval Do no try to remove comments (in such a case, we consider that each line is a request, so use also $linelengthlimit=0)
* @param int $offsetforchartofaccount Offset to use to load chart of account table to update sql on the fly to add offset to rowid and account_parent value
* @param int $colspan 2=Add a colspan=2 on td
* @param int $onlysqltoimportwebsite Only sql resquests used to import a website template are allowed
* @param string $database Database (replace __DATABASE__ with this value)
* @return int <=0 if KO, >0 if OK
*/
function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handler = '', $okerror = 'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0)
function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler = '', $okerror = 'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database = '')
{
global $db, $conf, $langs, $user;
@@ -327,7 +328,7 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle
if ($sql) {
// Test if th SQL is allowed SQL
if ($onlysqltoimportwebsite) {
$newsql = str_replace(array("\'"), '__BACKSLASHQUOTE__', $sql); // Replace the \' seque,ce
$newsql = str_replace(array("\'"), '__BACKSLASHQUOTE__', $sql); // Replace the \' char
// Remove all strings contents including the ' so we can analyse SQL instruction only later
$l = strlen($newsql);
@@ -389,6 +390,10 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle
$sql = preg_replace('/__HANDLER__/i', "'".$db->escape($handler)."'", $sql);
}
if (!empty($database)) {
$sql = preg_replace('/__DATABASE__/i', "'".$db->escape($database)."'", $sql);
}
$newsql = preg_replace('/__ENTITY__/i', (!empty($entity) ? $entity : $conf->entity), $sql);
// Add log of request