From 88e441412c23e1efeb8208220d4f4c10ae9104b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 01:35:59 +0100 Subject: [PATCH 01/11] CSS --- htdocs/compta/bank/various_payment/list.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 48da6483152..9c936c1d943 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -466,14 +466,18 @@ if ($result) // Project if ($arrayfields['project']['checked']) { - $proj->fetch($obj->fk_project); - print ''.$proj->getNomUrl(1).''; + print ''; + if ($obj->fk_project > 0) { + $proj->fetch($obj->fk_project); + print $proj->getNomUrl(1); + } + print ''; if (!$i) $totalarray['nbfield']++; } // Bank account if ($arrayfields['bank']['checked']) { - print ''; + print ''; if ($obj->bid > 0) { $accountstatic->id = $obj->bid; From e590fb36adeb3338b8a3f50d7e85d07edb846b43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 01:53:36 +0100 Subject: [PATCH 02/11] Log for debug --- test/phpunit/RestAPIUserTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 2bce51e2a05..979daa521b9 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -164,11 +164,11 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase print __METHOD__." Request GET url=".$url."\n"; $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); - //print __METHOD__." Result for unexisting user: ".var_export($result, true)."\n"; + print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); - $this->assertNotNull($object, "Parsing of json result must no be null"); + $this->assertNotNull($object, "Parsing of json result must not be null"); $this->assertEquals(404, $object['error']['code']); $url = $this->api_url.'/users/1?api_key='.$this->api_key; @@ -179,7 +179,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); - $this->assertNotNull($object, "Parsing of json result must no be null"); + $this->assertNotNull($object, "Parsing of json result must not be null"); $this->assertEquals(1, $object['statut']); } @@ -222,7 +222,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $body = json_encode($bodyobj); print __METHOD__." Request POST url=".$url."\n"; $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); - print __METHOD__." Result code for creating user ".var_export($result, true)."\n"; + print __METHOD__." rclsesult code for creating user ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); $resid=json_decode($result['content'], true); From 11b15557ebcf0625e9645b61ad97176949fd3840 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 02:09:11 +0100 Subject: [PATCH 03/11] Clean code --- htdocs/user/class/api_users.class.php | 10 ++++++---- test/phpunit/RestAPIUserTest.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index e68ecb8bc1d..eb377b7685e 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -314,11 +314,13 @@ class Users extends DolibarrApi /** * Update account * - * @param int $id Id of account to update - * @param array $request_data Datas - * @return array + * @param int $id Id of account to update + * @param array $request_data Datas + * @return array|mixed Record after update * - * @throws RestException + * @throws RestException 401 Not allowed + * @throws RestException 404 Not found + * @throws RestException 500 System error */ public function put($id, $request_data = null) { diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 979daa521b9..d74ecb5534f 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -169,7 +169,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); $this->assertNotNull($object, "Parsing of json result must not be null"); - $this->assertEquals(404, $object['error']['code']); + $this->assertEquals(404, $object['error']['code'], 'Error code is not 404'); $url = $this->api_url.'/users/1?api_key='.$this->api_key; From 65dc7667651a41c5b50d0481e95022b19c4a7d2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 02:12:13 +0100 Subject: [PATCH 04/11] Code comment --- htdocs/api/class/api_login.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 25765e7f7e5..17d8916b9aa 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -48,8 +48,8 @@ class Login * @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access) * @return array Response status and user token * - * @throws RestException 403 - * @throws RestException 500 + * @throws RestException 403 Access denied + * @throws RestException 500 System error * * @url GET / * @url POST / From e9129154e448392e115b3540d5d4485802016aa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 02:16:22 +0100 Subject: [PATCH 05/11] Log --- test/phpunit/RestAPIUserTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index d74ecb5534f..d2dd8660922 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -164,7 +164,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase print __METHOD__." Request GET url=".$url."\n"; $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); - print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n"; + //print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); @@ -175,7 +175,7 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase print __METHOD__." Request GET url=".$url."\n"; $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); - //print __METHOD__." Result for existing user user: ".var_export($result, true)."\n"; + print __METHOD__." result for get on an existing user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; $this->assertEquals($result['curl_error_no'], ''); $object=json_decode($result['content'], true); From 11a122176d2587faeab5eeb86819a789ba11e3b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 02:33:11 +0100 Subject: [PATCH 06/11] Clean code --- htdocs/api/class/api.class.php | 2 +- htdocs/user/class/api_users.class.php | 20 ++++++++++---------- test/phpunit/RestAPIUserTest.php | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index e101fb89602..89d170feb60 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -173,7 +173,7 @@ class DolibarrApi unset($object->name_bis); unset($object->newref); - if ($object->table_element != 'ticket') { + if (!isset($object->table_element) || $object->table_element != 'ticket') { unset($object->comments); } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index eb377b7685e..d50fec76353 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -142,11 +142,11 @@ class Users extends DolibarrApi * Get properties of an user object * * @param int $id ID of user - * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) - * @return array|mixed data without useless information + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed data without useless information * - * @throws RestException 401 Insufficient rights - * @throws RestException 404 User or group not found + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found */ public function get($id, $includepermissions = 0) { @@ -177,13 +177,13 @@ class Users extends DolibarrApi * Get properties of an user object by login * * @param string $login Login of user - * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) - * @return array|mixed data without useless information + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed Data without useless information * * @url GET login/{login} * - * @throws RestException 401 Insufficient rights - * @throws RestException 404 User or group not found + * @throws RestException 401 Insufficient rights + * @throws RestException 404 User or group not found */ public function getByLogin($login, $includepermissions = 0) { @@ -211,8 +211,8 @@ class Users extends DolibarrApi * Get properties of an user object by Email * * @param string $email Email of user - * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) - * @return array|mixed data without useless information + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) + * @return array|mixed Data without useless information * * @url GET email/{email} * diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index d2dd8660922..6222f7fcaf7 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -190,7 +190,6 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase */ public function testRestCreateUser() { - // attemp to create without mandatory fields : $url = $this->api_url.'/users?api_key='.$this->api_key; $addheaders=array('Content-Type: application/json'); From ea0ae758a35cabf4715bb1f1c781cc3a8334678d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 02:48:32 +0100 Subject: [PATCH 07/11] Fix warnings --- htdocs/webservices/server_actioncomm.php | 8 ++++---- htdocs/webservices/server_contact.php | 8 ++++---- htdocs/webservices/server_order.php | 10 +++++----- htdocs/webservices/server_productorservice.php | 10 +++++----- htdocs/webservices/server_project.php | 6 +++--- htdocs/webservices/server_thirdparty.php | 10 +++++----- htdocs/webservices/server_user.php | 4 ++-- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 7864c93243f..140351e7d21 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -122,7 +122,7 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -315,7 +315,7 @@ function getActionComm($authentication, $id) //Get extrafield values $actioncomm->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -454,7 +454,7 @@ function createActionComm($authentication, $actioncomm) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -551,7 +551,7 @@ function updateActionComm($authentication, $actioncomm) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 9abc7b6088f..6fc521a43c7 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -127,7 +127,7 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -319,7 +319,7 @@ function getContact($authentication, $id, $ref_ext) //Get extrafield values $contact->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -424,7 +424,7 @@ function createContact($authentication, $contact) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -671,7 +671,7 @@ function updateContact($authentication, $contact) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 62e8dc99d72..30c105d7192 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -120,7 +120,7 @@ $extrafield_line_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_line_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -224,7 +224,7 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -705,7 +705,7 @@ function createOrder($authentication, $order) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -743,7 +743,7 @@ function createOrder($authentication, $order) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -948,7 +948,7 @@ function updateOrder($authentication, $order) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index f723dcfd054..f285d245030 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -142,7 +142,7 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -436,7 +436,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' //Get extrafield values $product->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -563,7 +563,7 @@ function createProductOrService($authentication, $product) $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -719,7 +719,7 @@ function updateProductOrService($authentication, $product) $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -1090,7 +1090,7 @@ function getProductsForCategory($authentication, $id, $lang = '') //Get extrafield values $tmpproduct->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index 9d4c93c9ce9..0817332c09f 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -169,7 +169,7 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -277,7 +277,7 @@ function createProject($authentication, $project) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -386,7 +386,7 @@ function getProject($authentication, $id = '', $ref = '') $extrafields->fetch_name_optionals_label($elementtype, true); //Get extrafield values - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { $project->fetch_optionals(); foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 3a1e911f510..5bde94cc0d5 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -130,7 +130,7 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -365,7 +365,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') //Get extrafield values $thirdparty->fetch_optionals(); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -481,7 +481,7 @@ function createThirdParty($authentication, $thirdparty) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -615,7 +615,7 @@ function updateThirdParty($authentication, $thirdparty) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -723,7 +723,7 @@ function getListOfThirdParties($authentication, $filterthirdparty) $extrafieldsOptions = array(); $obj = $db->fetch_object($resql); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 6f7ed5c10aa..25cb2324412 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -193,7 +193,7 @@ $extrafield_array = null; if (is_array($extrafields) && count($extrafields) > 0) { $extrafield_array = array(); } -if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) +if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { @@ -599,7 +599,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); - if (is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) + if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key=>$label) { From 3586da75a2c38d5ed74a551b6d02994d3019d786 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 02:52:49 +0100 Subject: [PATCH 08/11] Fix warning --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dd80c660e71..884d8eac496 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4461,7 +4461,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $savlimit = $limit; $savtotalnboflines = $totalnboflines; - $totalnboflines = abs($totalnboflines); + $totalnboflines = abs((int) $totalnboflines); if ($picto == 'setup') $picto = 'title_setup.png'; if (($conf->browser->name == 'ie') && $picto == 'generic') $picto = 'title.gif'; From 6c2a17b29ad629bc7922c1ee1891d8cda44026aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 02:59:00 +0100 Subject: [PATCH 09/11] Fix warning --- htdocs/contrat/list.php | 6 +++--- htdocs/core/class/notify.class.php | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index d273dd7cdf7..72a8ec2974d 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -614,14 +614,14 @@ while ($i < min($num, $limit)) $socstatic->logo = $obj->logo; $socstatic->country_id = $obj->country_id; $socstatic->country_code = ''; - $socstatic->country_label = '';*/ + $socstatic->country = '';*/ if ($obj->country_id > 0) { if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) { $tmparray = getCountry($obj->country_id, 'all'); $cacheCountryIDCode[$obj->country_id] = array('code'=> empty($tmparray['code']) ? '' : $tmparray['code'], 'label' => empty($tmparray['label']) ? '' : $tmparray['label']); } $socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code']; - $socstatic->country_label = $cacheCountryIDCode[$obj->country_id]['label']; + $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label']; } @@ -695,7 +695,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - print $socstatic->country_label; + print $socstatic->country; print ''; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 6f60f6cdca6..f9f1c3b99ef 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -112,6 +112,7 @@ class Notify $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); + $texte = ''; $nb = -1; if (is_array($listofnotiftodo)) { $nb = count($listofnotiftodo); @@ -170,6 +171,8 @@ class Notify if (is_object($object)) { $valueforthreshold = $object->total_ht; } + + $sqlnotifcode = ''; if ($notifcode) { if (is_numeric($notifcode)) { $sqlnotifcode = " AND n.fk_action = ".$notifcode; // Old usage From 5ef3ffbdc63e7fdeaab4e203f110c535c5cd99e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 03:03:38 +0100 Subject: [PATCH 10/11] Fix warning --- htdocs/core/class/utils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 93eaeb6d4f2..07b67e30062 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -168,7 +168,7 @@ class Utils $this->output = $langs->trans("PurgeNDirectoriesDeleted", $countdeleted); if ($count > $countdeleted) $this->output .= '
'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted)); } else { - $this->output = $langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)' : ''); + $this->output = $langs->trans("PurgeNothingToDelete").(in_array('tempfilesold', $choicesarray) ? ' (older than 24h for temp files)' : ''); } // Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them From a0440fbe8841a8a6b2582f2e10cab928bb85ba8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Dec 2020 03:06:52 +0100 Subject: [PATCH 11/11] Removed warnings --- htdocs/core/boxes/box_funnel_of_prospection.php | 4 ++-- htdocs/core/boxes/modules_boxes.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 6ffce6d781b..5b6130d8eb2 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -61,9 +61,9 @@ class box_funnel_of_prospection extends ModeleBoxes $this->db = $db; - $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1); // Not enabled by default, still need some work + $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1 ? 1 : 0); // Not enabled by default, still need some work - $this->hidden = !($user->rights->projet->lire); + $this->hidden = empty($user->rights->projet->lire); } /** diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 1e32a28f25c..9faf45932e2 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -56,7 +56,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box /** * @var boolean Condition to have widget visible (in most cases, permissions) */ - public $hidden = 0; + public $hidden = false; /** * @var int Box definition database ID