diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 24e2a40bd85..8cf0dc801ce 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -1193,11 +1193,10 @@ class FormFile
* @param int $addfilterfields Add the line with filters
* @param int $disablecrop Disable crop feature on images (-1 = auto, prefer to set it explicitly to 0 or 1)
* @param string $moreattrondiv More attributes on the div for responsive. Example 'style="height:280px; overflow: auto;"'
- * @param int $noCreateEcmFile Manages ECM file creation
* @return int Return integer <0 if KO, nb of files shown if OK
* @see list_of_autoecmfiles()
*/
- public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1, $moreattrondiv = '', $noCreateEcmFile = 0)
+ public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1, $moreattrondiv = '')
{
// phpcs:enable
global $user, $conf, $langs, $hookmanager, $form;
@@ -1324,7 +1323,7 @@ class FormFile
// Get list of files stored into database for same relative directory
if ($relativedir) {
- completeFileArrayWithDatabaseInfo($filearray, $relativedir, $noCreateEcmFile);
+ completeFileArrayWithDatabaseInfo($filearray, $relativedir);
//var_dump($sortfield.' - '.$sortorder);
if ($sortfield && $sortorder) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 3512054acc4..7aa51b29c3b 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -276,6 +276,7 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s
} else {
$sql .= " AND filepath = '".$db->escape($path)."'";
}
+
$resql = $db->query($sql);
if ($resql) {
$file_list = array();
@@ -335,10 +336,9 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s
*
* @param array $filearray Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) Array of files obtained using dol_dir_list
* @param string $relativedir Relative dir from DOL_DATA_ROOT
- * @param int $noCreateEcmFile Manages ECM file creation
* @return void
*/
-function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $noCreateEcmFile = 0)
+function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
{
global $conf, $db, $user;
@@ -394,6 +394,7 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $noCreateE
break;
}
}
+
if (!$found) { // This happen in transition toward version 6, or if files were added manually into os dir.
$filearray[$key]['position'] = '999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position
$filearray[$key]['cover'] = 0;
@@ -402,7 +403,7 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $noCreateE
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filearray[$key]['fullname']);
- if (!preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filename) && $noCreateEcmFile == 0) { // If not a tmp file
+ if (!preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filename)) { // If not a tmp file
dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it");
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($db);
diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php
index 013f4b0650f..7cac5150b48 100644
--- a/htdocs/ecm/class/ecmfiles.class.php
+++ b/htdocs/ecm/class/ecmfiles.class.php
@@ -346,6 +346,7 @@ class EcmFiles extends CommonObject
$sql .= ')';
$this->db->begin();
+
$resql = $this->db->query($sql);
if (!$resql) {
$error++;