FIX several critical bugs in migration of directory of users

This commit is contained in:
Laurent Destailleur 2018-12-07 19:35:38 +01:00
parent 2621af96d6
commit f99d9a7da9
2 changed files with 17 additions and 7 deletions

View File

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

View File

@ -4850,8 +4850,6 @@ function migrate_user_photospath()
{
while ($obj = $db->fetch_object($resql))
{
print '.';
$fuser->fetch($obj->uid);
//echo '<hr>'.$fuser->id.' -> '.$fuser->entity;
$entity = (empty($fuser->entity) ? 1 : $fuser->entity);
@ -4863,7 +4861,8 @@ function migrate_user_photospath()
if ($dir)
{
$origin = $dir .'/'. get_exdir($fuser->id,2,0,0,$fuser,'user');
//print "Process user id ".$fuser->id."<br>\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);
@ -4892,8 +4891,10 @@ function migrate_user_photospath()
{
if ($thumb == '.' || $thumb == '..') continue;
//print $origin.'/'.$file.'/'.$thumb.' -> '.$destin.'/'.$file.'/'.$thumb.'<br>'."\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);
@ -4903,8 +4904,10 @@ function migrate_user_photospath()
{
if (! dol_is_file($destin.'/'.$file))
{
//print $origin.'/'.$file.' -> '.$destin.'/'.$file.'<br>'."\n";
print '.';
dol_move($origin.'/'.$file, $destin.'/'.$file, 0, 0, 0, 1);
dol_copy($origin.'/'.$file, $destin.'/'.$file, 0, 0);
//var_dump('eee');exit;
}
}
}