diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 2c95650f197..782730b81f3 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -621,7 +621,7 @@ class Website extends CommonObject */ public function createFromClone($user, $fromid, $newref, $newlang = '') { - global $conf; + global $conf, $langs; global $dolibarr_main_data_root; $now = dol_now(); @@ -663,12 +663,15 @@ class Website extends CommonObject $object->virtualhost = ''; $object->date_creation = $now; $object->fk_user_creat = $user->id; + $object->position = $object->position + 1; + if (empty($object->lang)) $object->lang = substr($langs->defaultlang, 0, 2); // Should not happen. Protection for corrupted site with no languages // Create clone $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); if ($result < 0) { $error++; + $this->error = $object->error; $this->errors = $object->errors; dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 6e3a582f7c6..4923a585454 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1774,6 +1774,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $objectnew = new Website($db); $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : '')); + if ($result < 0) { $error++;