Revert "add param nocreateEcmFile (#33770)"

This reverts commit 0bd93fa05a.
This commit is contained in:
ldestailleur 2025-04-10 14:19:49 +02:00
parent 6c6aa70d0b
commit e276def96d
3 changed files with 7 additions and 6 deletions

View file

@ -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)

View file

@ -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<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string}> $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);

View file

@ -346,6 +346,7 @@ class EcmFiles extends CommonObject
$sql .= ')';
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error++;