From 9e9a8894ea17c198fee8e3e2d68dd8d81d4de6d8 Mon Sep 17 00:00:00 2001 From: jean Date: Tue, 17 Mar 2015 14:20:08 +0100 Subject: [PATCH 1/9] Add global $langs to method, necessary for triggers to function correctly --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 3d12352903f..4db72d48814 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -154,7 +154,7 @@ class ProductFournisseur extends Product */ function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0) { - global $conf; + global $conf, $langs; // Clean parameter if (empty($qty)) $qty=0; From a2676e57684fdea66934291b698199a91204072b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Mar 2015 21:06:55 +0100 Subject: [PATCH 2/9] Fix: the type of notification sent was not filled --- htdocs/core/class/notify.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index db88671f7ff..ac63b3e48c5 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -423,7 +423,7 @@ class Notify if ($mailfile->sendfile()) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, objet_id, email)"; - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$object->socid.", null, '".$obj->type."', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; + $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$actiondefid.", ".$object->socid.", null, 'email', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; if (! $this->db->query($sql)) { dol_print_error($this->db); From d442ac328c0a2d4b8ac2bb6d14fb64da1e6b96d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Mar 2015 12:34:03 +0100 Subject: [PATCH 3/9] Fix: some replacement tags were missing --- htdocs/fourn/commande/card.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index eefd5c961e2..d42c649f044 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1966,8 +1966,13 @@ elseif (! empty($object->id)) $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; + + $object->fetch_projet(); // Tableau des substitutions $formmail->substit['__ORDERREF__']=$object->ref; + $formmail->substit['__ORDERSUPPLIERREF__']=$object->ref_supplier; + $formmail->substit['__THIRPARTY_NAME__'] = $object->thirdparty->name; + $formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); $formmail->substit['__SIGNATURE__']=$user->signature; $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; From b0e928c213ed9cd3715d5fa6d56c0d46b270b1e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Mar 2015 15:26:00 +0100 Subject: [PATCH 4/9] Disable migration with bugged versions --- htdocs/install/upgrade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 22c18c15fee..1e1ba08b6f9 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -193,9 +193,9 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) // Test database version is not forbidden for migration $dbversion_disallowed=array( array('type'=>'mysql','version'=>array(5,5,40)), - array('type'=>'mysqli','version'=>array(5,5,40)) - //,array('type'=>'mysql','version'=>array(5,5,41)), - //array('type'=>'mysqli','version'=>array(5,5,41)) + array('type'=>'mysqli','version'=>array(5,5,40)), + array('type'=>'mysql','version'=>array(5,5,41)), + array('type'=>'mysqli','version'=>array(5,5,41)) ); $listofforbiddenversion=''; foreach ($dbversion_disallowed as $dbversion_totest) From 0784e9638a7ab88df303b28d1c3d1b3941f5fff1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Mar 2015 17:57:40 +0100 Subject: [PATCH 5/9] The test on db version must not lock the phpunit --- .travis.yml | 12 +++---- htdocs/install/upgrade.php | 64 +++++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index c97b547e499..6c5833ccfdb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -91,13 +91,13 @@ before_script: script: - cd htdocs/install - date -# - php upgrade.php 3.4.0 3.5.0 > upgrade.log -# - php upgrade2.php 3.4.0 3.5.0 > upgrade2.log - - php upgrade.php 3.5.0 3.6.0 >> upgrade.log - - php upgrade2.php 3.5.0 3.6.0 >> upgrade2.log - - php upgrade.php 3.6.0 3.7.0 >> upgrade.log +# - php upgrade.php 3.4.0 3.5.0 ignoredbversion > upgrade.log +# - php upgrade2.php 3.4.0 3.5.0 ignoredbversion > upgrade2.log + - php upgrade.php 3.5.0 3.6.0 ignoredbversion >> upgrade.log + - php upgrade2.php 3.5.0 3.6.0 ignoredbversion >> upgrade2.log + - php upgrade.php 3.6.0 3.7.0 ignoredbversion >> upgrade.log # - cat upgrade360370.log - - php upgrade2.php 3.6.0 3.7.0 >> upgrade2.log + - php upgrade2.php 3.6.0 3.7.0 ignoredbversion >> upgrade2.log # - cat upgrade2.log - cd ../.. - date diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 1e1ba08b6f9..126c0896c80 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -19,9 +19,11 @@ * Upgrade scripts can be ran from command line with syntax: * * cd htdocs/install - * php upgrade.php 3.4.0 3.5.0 + * php upgrade.php 3.4.0 3.5.0 [dirmodule|ignoredbversion] * php upgrade2.php 3.4.0 3.5.0 * + * Option 'dirmodule' allows to provide a path for an external module, so we migrate from command line a script from a module. + * Option 'ignoredbversion' allows to run migration even if database is a bugged database version. * Return code is 0 if OK, >0 if error */ @@ -55,7 +57,8 @@ $setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):'auto'; $langs->setDefaultLang($setuplang); $versionfrom=GETPOST("versionfrom",'',3)?GETPOST("versionfrom",'',3):(empty($argv[1])?'':$argv[1]); $versionto=GETPOST("versionto",'',3)?GETPOST("versionto",'',3):(empty($argv[2])?'':$argv[2]); -$versionmodule=GETPOST("versionmodule",'',3)?GETPOST("versionmodule",'',3):(empty($argv[3])?'':$argv[3]); +$dirmodule=GETPOST("dirmodule",'',3)?GETPOST("dirmodule",'',3):(empty($argv[3])?'':$argv[3]); +$ignoredbversion=GETPOST('ignoredbversion','',3)?GETPOST('ignoredbversion','',3):(empty($argv[3])?'':$argv[3]); $langs->load("admin"); $langs->load("install"); @@ -191,31 +194,34 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) } // Test database version is not forbidden for migration - $dbversion_disallowed=array( - array('type'=>'mysql','version'=>array(5,5,40)), - array('type'=>'mysqli','version'=>array(5,5,40)), - array('type'=>'mysql','version'=>array(5,5,41)), - array('type'=>'mysqli','version'=>array(5,5,41)) - ); - $listofforbiddenversion=''; - foreach ($dbversion_disallowed as $dbversion_totest) - { - if ($dbversion_totest['type'] == $db->type) $listofforbiddenversion.=($listofforbiddenversion?', ':'').join('.',$dbversion_totest['version']); - } - foreach ($dbversion_disallowed as $dbversion_totest) - { - //print $db->type.' - '.join('.',$versionarray).' - '.versioncompare($dbversion_totest['version'],$versionarray)."
\n"; - if ($dbversion_totest['type'] == $db->type - && (versioncompare($dbversion_totest['version'],$versionarray) == 0 || versioncompare($dbversion_totest['version'],$versionarray)<=-4 || versioncompare($dbversion_totest['version'],$versionarray)>=4) - ) - { - // Warning: database version too low. - print '
'.$langs->trans("ErrorDatabaseVersionForbiddenForMigration",join('.',$versionarray),$listofforbiddenversion)."
".$langs->trans("Error")."\n"; - dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionForbiddenForMigration",join('.',$versionarray),$listofforbiddenversion)); - $ok=0; - break; - } - } + if (empty($ignoredbversion)) + { + $dbversion_disallowed=array( + array('type'=>'mysql','version'=>array(5,5,40)), + array('type'=>'mysqli','version'=>array(5,5,40)), + array('type'=>'mysql','version'=>array(5,5,41)), + array('type'=>'mysqli','version'=>array(5,5,41)) + ); + $listofforbiddenversion=''; + foreach ($dbversion_disallowed as $dbversion_totest) + { + if ($dbversion_totest['type'] == $db->type) $listofforbiddenversion.=($listofforbiddenversion?', ':'').join('.',$dbversion_totest['version']); + } + foreach ($dbversion_disallowed as $dbversion_totest) + { + //print $db->type.' - '.join('.',$versionarray).' - '.versioncompare($dbversion_totest['version'],$versionarray)."
\n"; + if ($dbversion_totest['type'] == $db->type + && (versioncompare($dbversion_totest['version'],$versionarray) == 0 || versioncompare($dbversion_totest['version'],$versionarray)<=-4 || versioncompare($dbversion_totest['version'],$versionarray)>=4) + ) + { + // Warning: database version too low. + print '
'.$langs->trans("ErrorDatabaseVersionForbiddenForMigration",join('.',$versionarray),$listofforbiddenversion)."
".$langs->trans("Error")."\n"; + dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorDatabaseVersionForbiddenForMigration",join('.',$versionarray),$listofforbiddenversion)); + $ok=0; + break; + } + } + } } // Force l'affichage de la progression @@ -370,7 +376,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) if ($ok) { $dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver - if (! empty($versionmodule)) $dir=dol_buildpath('/'.$versionmodule.'/sql/',0); + if (! empty($dirmodule)) $dir=dol_buildpath('/'.$dirmodule.'/sql/',0); // Clean last part to exclude minor version x.y.z -> x.y $newversionfrom=preg_replace('/(\.[0-9]+)$/i','.0',$versionfrom); @@ -475,7 +481,7 @@ $ret=0; if (! $ok && isset($argv[1])) $ret=1; dol_syslog("Exit ".$ret); -pFooter(((! $ok && empty($_GET["ignoreerrors"])) || $versionmodule),$setuplang); +pFooter(((! $ok && empty($_GET["ignoreerrors"])) || $dirmodule),$setuplang); if ($db->connected) $db->close(); From eeb09b83a10fd4dcb843b3afde336866258ff014 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Mar 2015 20:50:46 +0100 Subject: [PATCH 6/9] The test on db version must not lock the phpunit --- htdocs/install/upgrade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 126c0896c80..359980763b0 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -57,8 +57,8 @@ $setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):'auto'; $langs->setDefaultLang($setuplang); $versionfrom=GETPOST("versionfrom",'',3)?GETPOST("versionfrom",'',3):(empty($argv[1])?'':$argv[1]); $versionto=GETPOST("versionto",'',3)?GETPOST("versionto",'',3):(empty($argv[2])?'':$argv[2]); -$dirmodule=GETPOST("dirmodule",'',3)?GETPOST("dirmodule",'',3):(empty($argv[3])?'':$argv[3]); -$ignoredbversion=GETPOST('ignoredbversion','',3)?GETPOST('ignoredbversion','',3):(empty($argv[3])?'':$argv[3]); +$dirmodule=((GETPOST("dirmodule",'',3) && GETPOST("dirmodule",'',3) != 'ignoredbversion'))?GETPOST("dirmodule",'',3):((empty($argv[3]) || $argv[3] == 'ignoredbversion')?'':$argv[3]); +$ignoredbversion=(GETPOST('ignoredbversion','',3)=='ignoredbversion')?GETPOST('ignoredbversion','',3):((empty($argv[3]) || $argv[3] != 'ignoredbversion')?'':$argv[3]); $langs->load("admin"); $langs->load("install"); From b8ed5533658b83e327faa50b38b694bd7c76ed25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Mar 2015 01:08:29 +0100 Subject: [PATCH 7/9] We must keep the @, some tools use it to know it is login page. --- htdocs/core/tpl/login.tpl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 29eda49a9a9..f9e22ed3812 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -29,7 +29,7 @@ if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1; $arrayofjs=array('/core/js/dst.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION))); // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second -$titleofloginpage=$langs->trans('Login').' '.$title; // title is defined by dol_loginfunction in security2.lib.php +$titleofloginpage=$langs->trans('Login').' @ '.$title; // title is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page. print top_htmlhead('',$titleofloginpage,0,0,$arrayofjs); ?> @@ -49,7 +49,6 @@ $(document).ready(function () {