From 6409cc06ae8d3827610497c8bda26b6671482080 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 22 Jul 2019 11:42:25 +0200 Subject: [PATCH 1/4] FIX duplicate on the check (TODO field $onetrtd not used ?) --- htdocs/core/class/commonobject.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7cf3273b818..b2826737d0d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6289,7 +6289,7 @@ abstract class CommonObject * @param array $params Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan) * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) - * @param string $onetrtd All fields in same tr td + * @param string $onetrtd All fields in same tr td (TODO field not used ?) * @return string */ function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='', $onetrtd=0) @@ -6386,10 +6386,7 @@ abstract class CommonObject $out .= ''; - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) - { - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } - } + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } if ($action == 'selectlines') { $colspan++; } From e92c6c87a0f20fda7690480d465c968fc469abf0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jul 2019 13:16:49 +0200 Subject: [PATCH 2/4] FIX API return 404 sometimes even if API exists --- htdocs/api/index.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index e55a30304a4..6788b208a2e 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -88,17 +88,22 @@ if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($ // index.php/xxx called by any REST client to run API +$reg=array(); preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg); // .../index.php/categories?sortfield=t.rowid&sortorder=ASC // Set the flag to say to refresh (when we reload the explorer, production must be for API call only) -$refreshcache=false; +/*$refreshcache=false; if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { $refreshcache=true; -} - +}*/ +// When in production mode, a file api/temp/routes.php is created with the API available of current call. +// But, if we set $refreshcache to false, so it may have only one API in the routes.php file if we make a call for one API without +// using the explorer. And when we make another call for another API, the API is not into the api/temp/routes.php and a 404 is returned. +// So we force refresh to each call. +$refreshcache=true; $api = new DolibarrApi($db, '', $refreshcache); //var_dump($api->r->apiVersionMap); @@ -115,7 +120,7 @@ UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', -// Call Explorer file for all APIs definitions +// Call Explorer file for all APIs definitions (this part is slow) if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { // Scan all API files to load them @@ -253,5 +258,6 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && //var_dump($api->r->apiVersionMap); //exit; -// Call API (we suppose we found it) +// Call API (we suppose we found it). +// The handle will use the file api/temp/routes.php to get data to run the API. If the file exists and the entry for API is not found, it will return 404. $api->r->handle(); From 8b81702dd7805d31a46f3a55ac6942de41bc5161 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jul 2019 13:23:42 +0200 Subject: [PATCH 3/4] Fix API 404 errors --- htdocs/api/index.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 6788b208a2e..38050592a37 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -93,17 +93,15 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg); // .../index.php/categories?sortfield=t.rowid&sortorder=ASC -// Set the flag to say to refresh (when we reload the explorer, production must be for API call only) -/*$refreshcache=false; +// When in production mode, a file api/temp/routes.php is created with the API available of current call. +// But, if we set $refreshcache to false, so it may have only one API in the routes.php file if we make a call for one API without +// using the explorer. And when we make another call for another API, the API is not into the api/temp/routes.php and a 404 is returned. +// So we force refresh to each call. +$refreshcache=(empty($conf->global->API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE) ? true : false); if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { $refreshcache=true; -}*/ -// When in production mode, a file api/temp/routes.php is created with the API available of current call. -// But, if we set $refreshcache to false, so it may have only one API in the routes.php file if we make a call for one API without -// using the explorer. And when we make another call for another API, the API is not into the api/temp/routes.php and a 404 is returned. -// So we force refresh to each call. -$refreshcache=true; +} $api = new DolibarrApi($db, '', $refreshcache); //var_dump($api->r->apiVersionMap); From 471a947e8abe8789fc49da2ed99c679cedd4349d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jul 2019 16:30:16 +0200 Subject: [PATCH 4/4] FIX Attachment was lost when we validate an expense report Conflicts: htdocs/expensereport/class/expensereport.class.php --- htdocs/expensereport/class/expensereport.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index dd2818f28bf..aec06b7972b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1120,11 +1120,10 @@ class ExpenseReport extends CommonObject $resql=$this->db->query($sql); if ($resql) { - if (!$notrigger) + if (! $error && ! $notrigger) { // Call trigger - $result=$this->call_trigger('EXPENSE_REPORT_VALIDATE',$fuser); - + $result=$this->call_trigger('EXPENSE_REPORT_VALIDATE', $fuser); if ($result < 0) { $error++; } @@ -1148,7 +1147,7 @@ class ExpenseReport extends CommonObject $dirdest = $conf->expensereport->dir_output.'/'.$newref; if (file_exists($dirsource)) { - dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); + dol_syslog(get_class($this)."::setValidate() rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) {