From 246e4a9f50367a8ec5ce9f7e6b14d321b708b3df Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Thu, 6 Jul 2023 09:28:01 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=20N=C2=B06123=20-=20Fix=20warnings=20when?= =?UTF-8?q?=20launching=20a=20backup=20on=20MariaDB=20>=20v10.6.1=20with?= =?UTF-8?q?=20localhost=20dbhost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/backup.class.inc.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php index 952ce2576..a28755afc 100644 --- a/setup/backup.class.inc.php +++ b/setup/backup.class.inc.php @@ -307,6 +307,7 @@ class DBBackup $sPortOption = self::GetMysqliCliSingleOption('port', $this->iDBPort); $sTlsOptions = self::GetMysqlCliTlsOptions($this->oConfig); + $sProtocolOption = self::GetMysqlCliTransportOption($this->sDBHost); $sMysqlVersion = CMDBSource::GetDBVersion(); $bIsMysqlSupportUtf8mb4 = (version_compare($sMysqlVersion, self::MYSQL_VERSION_WITH_UTF8MB4_IN_PROGRAMS) === -1); @@ -327,8 +328,8 @@ EOF; // Note: opt implicitely sets lock-tables... which cancels the benefit of single-transaction! // skip-lock-tables compensates and allows for writes during a backup - $sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1"; - $sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables"; + $sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1"; + $sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables"; // Now run the command for real $this->LogInfo("backup: generate data file with command: $sCommandDisplay"); @@ -521,6 +522,24 @@ EOF; return ' --'.$sCliArgName.'='.self::EscapeShellArg($sData); } + /** + * @param string $sHost + * + * @return string . + + * @since 2.7.9 3.0.4 3.1.1 N°6123 + */ + public static function GetMysqlCliTransportOption(string $sHost) + { + $sTransportOptions = ''; + + if($sHost === 'localhost'){ + $sTransportOptions = '--protocol=tcp'; + } + + return $sTransportOptions; + } + /** * @return string the command to launch mysqldump (without its params) */ From 3048c8c41fc64b90cd9075254115f17da151485e Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Thu, 6 Jul 2023 09:52:00 +0200 Subject: [PATCH 2/5] =?UTF-8?q?N=C2=B05560=20-=20Display=20an=20error=20wh?= =?UTF-8?q?en=20trying=20to=20regenerate=20an=20expired=20OAuth=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/AjaxOauthClientController.php | 17 ++++++++++------- .../Client/OAuth/OAuthClientProviderFactory.php | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php b/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php index 65523046b..4ec94b2f6 100644 --- a/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php +++ b/datamodels/2.x/itop-oauth-client/src/Controller/AjaxOauthClientController.php @@ -11,6 +11,7 @@ use Combodo\iTop\Application\TwigBase\Controller\Controller; use Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory; use Dict; use IssueLog; +use League\OAuth2\Client\Provider\Exception\IdentityProviderException; use MetaModel; use utils; @@ -64,13 +65,15 @@ class AjaxOauthClientController extends Controller } if (isset($aQuery['code'])) { $sCode = $aQuery['code']; - $oAccessToken = OAuthClientProviderFactory::GetAccessTokenFromCode($oOAuthClient, $sCode); - - $oOAuthClient->SetAccessToken($oAccessToken); - - - - $aResult['status'] = 'success'; + try { + $oAccessToken = OAuthClientProviderFactory::GetAccessTokenFromCode($oOAuthClient, $sCode); + $oOAuthClient->SetAccessToken($oAccessToken); + $aResult['status'] = 'success'; + } + catch (IdentityProviderException $e) { + $aResult['status'] = 'error'; + $aResult['error_description'] = $e->getMessage(); + } } } else { $aResult['status'] = 'error'; diff --git a/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php b/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php index 66230eb3e..77006d436 100644 --- a/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php +++ b/sources/Core/Authentication/Client/OAuth/OAuthClientProviderFactory.php @@ -74,6 +74,7 @@ class OAuthClientProviderFactory * @return AccessTokenInterface * @throws \ArchivedObjectException * @throws \CoreException + * @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException */ public static function GetAccessTokenFromCode(OAuthClient $oOAuthClient, $sCode) { @@ -109,7 +110,7 @@ class OAuthClientProviderFactory /** * @param \DBObject $oOAuthClient * - * @return mixed + * @return OAuthClientProviderAbstract * @throws \ArchivedObjectException * @throws \CoreException */ From f94d67ab35206b4933ab0b14d61e69a2f3d561b1 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Thu, 6 Jul 2023 10:28:10 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=20N=C2=B06340=20-=20Fix=20permission=20ref?= =?UTF-8?q?used=20when=20sending=20an=20email=20and=20renewing=20OAuth=20t?= =?UTF-8?q?oken=20in=20synchronous=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml b/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml index 52f751d49..c1efa7281 100644 --- a/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml +++ b/datamodels/2.x/itop-oauth-client/datamodel.itop-oauth-client.xml @@ -202,6 +202,7 @@ $this->Set('refresh_token', $oAccessToken->getRefreshToken()); } $this->Set('status', 'active'); + $this->AllowWrite(); $this->DBUpdate(); } ]]> From aa1834170b2dbd1423d622efa2c2f5df73772b54 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Thu, 6 Jul 2023 14:31:54 +0200 Subject: [PATCH 4/5] =?UTF-8?q?N=C2=B06427=20-=20Fix=20SwiftMailer=20not?= =?UTF-8?q?=20retrieving=20sendmail=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/Core/Email/EmailSwiftMailer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sources/Core/Email/EmailSwiftMailer.php b/sources/Core/Email/EmailSwiftMailer.php index 4d71ffa97..abb335c66 100644 --- a/sources/Core/Email/EmailSwiftMailer.php +++ b/sources/Core/Email/EmailSwiftMailer.php @@ -181,7 +181,11 @@ class EmailSwiftMailer extends EMail case 'PHPMail': default: - $oTransport = new Swift_SendmailTransport(); + // Retrieve sendmail path or select a default one as SwiftMailer is not doing it anymore + $sSendmailPath = ini_get('sendmail_path'); + $sSendmailPath = ($sSendmailPath === false || $sSendmailPath === '') ? '/usr/sbin/sendmail -bs' : $sSendmailPath; + + $oTransport = new Swift_SendmailTransport($sSendmailPath); } $oMailer = new Swift_Mailer($oTransport); From 264a8cd70adba2e074f57506b418d84ca66cd15a Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 6 Jul 2023 15:28:32 +0200 Subject: [PATCH 5/5] =?UTF-8?q?N=C2=B06494=20-=20Some=20tests=20are=20run?= =?UTF-8?q?=20twice,=20some=20never?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit a2a0b2cd0b8f109d2f2e454c2ac73db1bc36a8b5) (cherry picked from commit 4c9ea0c9d4792ca6ba9901b47413837f996fc2d3) # Conflicts: # tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php --- .../integration-tests/DictionariesConsistencyTest.php | 3 +++ .../iTopDesignFormatChecklistTest.php | 6 +++--- tests/php-unit-tests/postbuild_integration.xml.dist | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php b/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php index e52500237..a3c95b8e2 100644 --- a/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php +++ b/tests/php-unit-tests/integration-tests/DictionariesConsistencyTest.php @@ -18,6 +18,9 @@ namespace Combodo\iTop\Test\UnitTest\Integration; use Combodo\iTop\Test\UnitTest\ItopTestCase; +/** + * @group beforeSetup + */ class DictionariesConsistencyTest extends ItopTestCase { /** diff --git a/tests/php-unit-tests/post-build-integration-tests/iTopDesignFormatChecklistTest.php b/tests/php-unit-tests/post-build-integration-tests/iTopDesignFormatChecklistTest.php index 875fd01ec..d707ace63 100644 --- a/tests/php-unit-tests/post-build-integration-tests/iTopDesignFormatChecklistTest.php +++ b/tests/php-unit-tests/post-build-integration-tests/iTopDesignFormatChecklistTest.php @@ -15,7 +15,7 @@ use PHPUnit\Exception; * * @package Combodo\iTop\Test\UnitTest\Setup */ -class TestForITopDesignFormatClass extends ItopTestCase +class iTopDesignFormatChecklistTest extends ItopTestCase { protected function setUp(): void { @@ -47,7 +47,7 @@ class TestForITopDesignFormatClass extends ItopTestCase $aErrors[] = "cannot retrieve itop_design datamodel version in $sDataModelFile:1"; continue; } - + $aDatamodelCurrentVersions[$sVersion] = $sVersion; } } @@ -159,4 +159,4 @@ class TestForITopDesignFormatClass extends ItopTestCase } return $aDataModelFiles; } -} \ No newline at end of file +} diff --git a/tests/php-unit-tests/postbuild_integration.xml.dist b/tests/php-unit-tests/postbuild_integration.xml.dist index b45e634bb..444df800f 100644 --- a/tests/php-unit-tests/postbuild_integration.xml.dist +++ b/tests/php-unit-tests/postbuild_integration.xml.dist @@ -16,6 +16,7 @@ stopOnRisky="false" stopOnSkipped="false" verbose="true" + printerClass="Sempro\PHPUnitPrettyPrinter\PrettyPrinter" > @@ -23,6 +24,7 @@ +