diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php
index 42af7f92635..70e79a6a3e5 100644
--- a/htdocs/ecm/class/ecmfiles.class.php
+++ b/htdocs/ecm/class/ecmfiles.class.php
@@ -180,8 +180,15 @@ class EcmFiles extends CommonObject
if (empty($this->date_m)) $this->date_m = dol_now();
// If ref not defined
- $ref = dol_hash($this->filepath.'/'.$this->filename, 3);
- if (! empty($this->ref)) $ref=$this->ref;
+ $ref = '';
+ if (! empty($this->ref))
+ {
+ $ref=$this->ref;
+ }
+ else {
+ include_once DOL_DOCUMENT_ROOT.'/lib/security.lib.php';
+ $ref = dol_hash($this->filepath.'/'.$this->filename, 3);
+ }
$maxposition=0;
if (empty($this->position)) // Get max used
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 13d7d341961..9e5072ba211 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -4860,7 +4860,8 @@ function migrate_user_photospath()
}
if ($dir)
{
- $origin = $dir .'/'. get_exdir($fuser->id,2,0,0,$fuser,'user');
+ //print "Process user id ".$fuser->id."
\n";
+ $origin = $dir .'/'. get_exdir($fuser->id,2,0,1,$fuser,'user'); // Use old behaviour to get x/y path
$destin = $dir .'/'. $fuser->id;
$origin_osencoded=dol_osencode($origin);
@@ -4888,8 +4889,10 @@ function migrate_user_photospath()
{
if ($thumb == '.' || $thumb == '..') continue;
+ //print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'
'."\n";
print '.';
- dol_move($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb, 0, 0, 0, 0);
+ dol_copy($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb, 0, 0);
+ //var_dump('aaa');exit;
}
}
// dol_delete_dir($origin.'/'.$file);
@@ -4899,8 +4902,10 @@ function migrate_user_photospath()
{
if (! dol_is_file($destin.'/'.$file))
{
+ //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n";
print '.';
- dol_move($origin.'/'.$file, $destin.'/'.$file, 0, 0, 0, 1);
+ dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0);
+ //var_dump('eee');exit;
}
}
}