From d0a1c523ca9245384fe440d1661bdacbe7b91039 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Dec 2018 19:35:38 +0100 Subject: [PATCH] FIX several critical bugs in migration of directory of users --- htdocs/ecm/class/ecmfiles.class.php | 11 +++++++++-- htdocs/install/upgrade2.php | 11 ++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) 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; } } }