From d12e2e592a605c191e4b8df949cb883e5bac15d2 Mon Sep 17 00:00:00 2001 From: odain Date: Fri, 21 Aug 2020 10:25:05 +0200 Subject: [PATCH 01/17] =?UTF-8?q?N=C2=B03265=20-=20Log=20stacktrace=20when?= =?UTF-8?q?=20cron=20exception=20raised=20with=20debug=20enabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/backgroundtask.class.inc.php | 18 ++++++++++++++++++ webservices/cron.php | 24 +++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/core/backgroundtask.class.inc.php b/core/backgroundtask.class.inc.php index db93f1310..6ab6b7a11 100644 --- a/core/backgroundtask.class.inc.php +++ b/core/backgroundtask.class.inc.php @@ -26,6 +26,24 @@ */ class BackgroundTask extends DBObject { + protected $bDebug = false; + + /** + * @return bool + */ + public function IsDebug(): bool + { + return $this->bDebug; + } + + /** + * @param bool $bDebug + */ + public function SetDebug(bool $bDebug): void + { + $this->bDebug = $bDebug; + } + public static function Init() { $aParams = array diff --git a/webservices/cron.php b/webservices/cron.php index 6b8ed2e51..87f2eef68 100644 --- a/webservices/cron.php +++ b/webservices/cron.php @@ -112,7 +112,14 @@ function RunTask($oProcess, BackgroundTask $oTask, $oStartDate, $iTimeLimit) } catch (Exception $e) // we shouldn't get so much exceptions... but we need to handle legacy code, and cron.php has to keep running { - $sMessage = 'Processing failed with message: '.$e->getMessage(); + if ($oTask->IsDebug()) + { + $sMessage = 'Processing failed with message: '.$e->getTraceAsString(); + } + else + { + $sMessage = 'Processing failed with message: '.$e->getMessage(); + } } $fDuration = microtime(true) - $fStart; if ($oTask->Get('total_exec_count') == 0) @@ -164,8 +171,18 @@ function RunTask($oProcess, BackgroundTask $oTask, $oStartDate, $iTimeLimit) * @param CLIPage|WebPage $oP * @param iProcess[] $aProcesses * @param boolean $bVerbose + * @param bool $bDebug + * + * @throws \ArchivedObjectException + * @throws \CoreCannotSaveObjectException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \CoreWarning + * @throws \MySQLException + * @throws \OQLException + * @throws \ReflectionException */ -function CronExec($oP, $aProcesses, $bVerbose) +function CronExec($oP, $aProcesses, $bVerbose, $bDebug=false) { $iStarted = time(); $iMaxDuration = MetaModel::GetConfig()->Get('cron_max_execution_time'); @@ -256,6 +273,7 @@ function CronExec($oP, $aProcesses, $bVerbose) { // New entry, let's create a new BackgroundTask record, and plan the first execution $oTask = new BackgroundTask(); + $oTask->SetDebug($bDebug); $oTask->Set('class_name', get_class($oProcess)); $oTask->Set('total_exec_count', 0); $oTask->Set('min_run_duration', 99999.999); @@ -591,7 +609,7 @@ try { if ($oMutex->TryLock()) { - CronExec($oP, $aProcesses, $bVerbose); + CronExec($oP, $aProcesses, $bVerbose, $bDebug); } else { From 4618f12d8a178917429666193c3c56a0a1a57044 Mon Sep 17 00:00:00 2001 From: acognet Date: Fri, 21 Aug 2020 18:50:27 +0200 Subject: [PATCH 02/17] =?UTF-8?q?N=C2=B03234=20-=20Notify=20on=20expiratio?= =?UTF-8?q?n=20not=20sending=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webservices/cron.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webservices/cron.php b/webservices/cron.php index 87f2eef68..980085fd5 100644 --- a/webservices/cron.php +++ b/webservices/cron.php @@ -223,8 +223,9 @@ function CronExec($oP, $aProcesses, $bVerbose, $bDebug=false) } $oNow = new DateTime(); + //don't recalculate next occurence if next_run_date is if (($oTask->Get('status') != 'active') - || ($oTask->Get('next_run_date') > $oNow->format('Y-m-d H:i:s'))) + || ($oTask->Get('next_run_date') > date('Y-m-d H:i:s',$iTimeLimit))) { if ($bVerbose) { From bb892cc1800636fe3b1b0672003d40844d9f5afd Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 27 Aug 2020 17:10:37 +0200 Subject: [PATCH 03/17] =?UTF-8?q?N=C2=B03078=20-=20Fix=20error=20on=20logi?= =?UTF-8?q?n=20while=20in=20maintenance=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/themehandler.class.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application/themehandler.class.inc.php b/application/themehandler.class.inc.php index de2fb21ca..192cbe1da 100644 --- a/application/themehandler.class.inc.php +++ b/application/themehandler.class.inc.php @@ -57,6 +57,10 @@ class ThemeHandler { try { + if (is_null(MetaModel::GetConfig())) + { + throw new CoreException('no config'); + } $sThemeId = MetaModel::GetConfig()->Get('backoffice_default_theme'); } catch(CoreException $oCompileException) From 70734e2b71ebf29994f50bf2d0e31440a0e0b333 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 28 Aug 2020 17:28:52 +0200 Subject: [PATCH 04/17] =?UTF-8?q?N=C2=B03188=20-=20Fix=20LIfeCycle=20visua?= =?UTF-8?q?lization=20details=20Fix=20js=20broken=20by=20the=20fix=20of=20?= =?UTF-8?q?N=C2=B0309?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/jquery.treeview.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/jquery.treeview.js b/js/jquery.treeview.js index 0e8fe5d4e..63ceaabd9 100644 --- a/js/jquery.treeview.js +++ b/js/jquery.treeview.js @@ -179,19 +179,19 @@ else { $(this) - .parent() + .parent() // swap classes for hitarea .find(">.hitarea") - .replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) - .replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) + .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) + .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) .end() // swap classes for parent li - .replaceClass( CLASSES.collapsable, CLASSES.expandable ) - .replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) + .swapClass( CLASSES.collapsable, CLASSES.expandable ) + .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) // find child lists .find( ">ul" ) - // toggle them - .heightToggleHide( settings.animated, settings.toggle ); + // toggle them + .heightToggle( settings.animated, settings.toggle ); } if ( settings.unique ) { @@ -295,4 +295,4 @@ // provide backwards compability $.fn.Treeview = $.fn.treeview; -})(jQuery); \ No newline at end of file +})(jQuery); From 328ec52c884d2ff05eed5b7796a452bc728d59a1 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 31 Aug 2020 11:38:24 +0200 Subject: [PATCH 05/17] =?UTF-8?q?N=C2=B03162=20-=20Remove=20default=20admi?= =?UTF-8?q?n=20phone=20number=20(can=20be=20incompatible=20with=20validati?= =?UTF-8?q?on=20pattern)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userrightsprofile.class.inc.php | 20 ++++++++++--------- .../userrightsprofile.db.class.inc.php | 10 +++------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index 294164d20..15155db7e 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -434,7 +434,7 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no organization class (or not writable)! if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) { - $oOrg = new Organization(); + $oOrg = MetaModel::NewObject('Organization'); $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); $iOrgId = $oOrg->DBInsertNoReload(); @@ -442,17 +442,13 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no Person class (or not writable)! if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) { - $oContact = new Person(); + $oContact = MetaModel::NewObject('Person'); $oContact->Set('name', 'My last name'); $oContact->Set('first_name', 'My first name'); if (MetaModel::IsValidAttCode('Person', 'org_id')) { $oContact->Set('org_id', $iOrgId); } - if (MetaModel::IsValidAttCode('Person', 'phone')) - { - $oContact->Set('phone', '+00 000 000 000'); - } $oContact->Set('email', 'my.email@foo.org'); $iContactId = $oContact->DBInsertNoReload(); } @@ -561,7 +557,7 @@ class UserRightsProfile extends UserRightsAddOnAPI /** * @param $oUser User - * @return array + * @return bool */ public function IsAdministrator($oUser) { @@ -571,16 +567,22 @@ class UserRightsProfile extends UserRightsAddOnAPI /** * @param $oUser User - * @return array + * @return bool */ public function IsPortalUser($oUser) { // UserRights caches the list for us return UserRights::HasProfile(PORTAL_PROFILE_NAME, $oUser); } + /** * @param $oUser User - * @return bool + * + * @return array + * @throws \ArchivedObjectException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \MySQLException */ public function ListProfiles($oUser) { diff --git a/addons/userrights/userrightsprofile.db.class.inc.php b/addons/userrights/userrightsprofile.db.class.inc.php index 2115f1b8d..f35fa6af7 100644 --- a/addons/userrights/userrightsprofile.db.class.inc.php +++ b/addons/userrights/userrightsprofile.db.class.inc.php @@ -535,7 +535,7 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no organization class (or not writable)! if (MetaModel::IsValidClass('Organization') && !MetaModel::IsAbstract('Organization')) { - $oOrg = new Organization(); + $oOrg = MetaModel::NewObject('Organization'); $oOrg->Set('name', 'My Company/Department'); $oOrg->Set('code', 'SOMECODE'); $oOrg::SetCurrentChange($oChange); @@ -544,17 +544,13 @@ class UserRightsProfile extends UserRightsAddOnAPI // Support drastic data model changes: no Person class (or not writable)! if (MetaModel::IsValidClass('Person') && !MetaModel::IsAbstract('Person')) { - $oContact = new Person(); + $oContact = MetaModel::NewObject('Person'); $oContact->Set('name', 'My last name'); $oContact->Set('first_name', 'My first name'); if (MetaModel::IsValidAttCode('Person', 'org_id')) { $oContact->Set('org_id', $iOrgId); } - if (MetaModel::IsValidAttCode('Person', 'phone')) - { - $oContact->Set('phone', '+00 000 000 000'); - } $oContact->Set('email', 'my.email@foo.org'); $oContact::SetCurrentChange($oChange); $iContactId = $oContact->DBInsertNoReload(); @@ -711,7 +707,7 @@ class UserRightsProfile extends UserRightsAddOnAPI public function LoadCache() { - if (!is_null($this->m_aProfiles)) return; + if (!is_null($this->m_aProfiles)) return false; // Could be loaded in a shared memory (?) $oKPI = new ExecutionKPI(); From 2806a76c1d82798da8254952d8f5965699ead208 Mon Sep 17 00:00:00 2001 From: bruno-ds Date: Mon, 31 Aug 2020 14:47:55 +0200 Subject: [PATCH 06/17] :greenheart: test readability --- test/integration/iTopModulesPhpVersionChecklistTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/iTopModulesPhpVersionChecklistTest.php b/test/integration/iTopModulesPhpVersionChecklistTest.php index b36022444..c71316265 100644 --- a/test/integration/iTopModulesPhpVersionChecklistTest.php +++ b/test/integration/iTopModulesPhpVersionChecklistTest.php @@ -57,7 +57,8 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase $matches ); - $this->assertSame($sExpectedVersion, $matches[1], "$sPhpFile file refer does not refer to current itop version ($matches[1] instead of expected $sExpectedVersion)"); + $this->assertRegExp("#$sExpectedVersion#", $matches[1], "$sPhpFile file refer does not refer to current itop version ($sModuleName/$matches[1] does not match regexp $sModuleName/$sExpectedVersion)"); + } public function iTopModulesPhpVersionProvider() @@ -83,7 +84,7 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase $sPath = $DatamodelsPath.'/*/module.*.php'; $aPhpFiles = glob($sPath); - $sExpectedVersion = \utils::GetItopPatchVersion(); + $sExpectedVersion = \utils::GetItopMinorVersion().'\.\d+'; // ie: 2.7\.\d+ (and yes, the 1st dot should be escaped, but, hey, it is good enough as it, ans less complex to read) $aTestCases = array(); foreach ($aPhpFiles as $sPhpFile) From fef8038f70c622a5469af015bf7b649a2d4e760e Mon Sep 17 00:00:00 2001 From: acognet Date: Mon, 31 Aug 2020 15:11:47 +0200 Subject: [PATCH 07/17] =?UTF-8?q?N=C2=B03261=20-=20Configure=20this=20list?= =?UTF-8?q?=20:=20sort=20icon=20disappears=20when=20descending=20sort=20is?= =?UTF-8?q?=20selected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/css-variables.scss | 5 +++++ css/light-grey.scss | 27 ++++++++++++++++++++++++--- images/bg.gif | Bin 64 -> 0 bytes images/desc.gif | Bin 54 -> 0 bytes 4 files changed, 29 insertions(+), 3 deletions(-) delete mode 100644 images/bg.gif delete mode 100644 images/desc.gif diff --git a/css/css-variables.scss b/css/css-variables.scss index 1df379aca..1bfda851d 100644 --- a/css/css-variables.scss +++ b/css/css-variables.scss @@ -127,3 +127,8 @@ $highlight-item-color: $white !default; $content-color: #eeeeee !default; $default-font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif !default; $icons-filter: hue-rotate(0deg) !default; + +%font-awesome-prerequisites{ + font-family: 'Font Awesome 5 Free'; + font-weight: 600; +} \ No newline at end of file diff --git a/css/light-grey.scss b/css/light-grey.scss index ebfd7e7fd..46e1943a6 100644 --- a/css/light-grey.scss +++ b/css/light-grey.scss @@ -2874,13 +2874,34 @@ a.summary, a.summary:hover { height: 12px; } .sort_none { - background: url($approot-relative + "images/bg.gif?v=" + $version) no-repeat center; + padding-right: 5px; + &::after { + @extend %font-awesome-prerequisites; + text-align: right; + content: '\f0dc'; + color: $complement-color; + float: right; + } } .sort_asc { - background: url($approot-relative + "images/desc.gif?v=" + $version) no-repeat center; + padding-right: 5px; + &::after { + @extend %font-awesome-prerequisites; + text-align: right; + content: '\f0d8'; + color: $complement-color; + float: right; + } } .sort_desc { - background: url($approot-relative + "images/asc.gif?v=" + $version) no-repeat center; + padding-right: 5px; + &::after { + @extend %font-awesome-prerequisites; + text-align: right; + content: '\f0d7'; + color: $complement-color; + float: right; + } } .sort_hidden { display: none; diff --git a/images/bg.gif b/images/bg.gif deleted file mode 100644 index e2d7d0e3c74e53f5eb697d5abfa3fc087a695fda..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 64 zcmZ?wbhEHb6lLIKXkcWJnR4X+|Nn|VSr{1@7#VaJfB+=Jz$D(&-*B4qR#HWXQP Date: Mon, 31 Aug 2020 17:15:59 +0200 Subject: [PATCH 08/17] =?UTF-8?q?N=C2=B03146=20-=20Affichage=20des=20class?= =?UTF-8?q?=20user=20dans=20l'import=20CSV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/csvimport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/csvimport.php b/pages/csvimport.php index 0cfcc4cd5..960ff18d3 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -50,7 +50,7 @@ try $sHtml = "