From 195056492ebe0b5619f1400a872f7ecdd73614d0 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 29 Jun 2021 16:45:18 +0200 Subject: [PATCH 01/10] :wrench: .editorConfig : enable var alignement --- .editorconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index bdd599d30..5a38344ce 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,7 +13,7 @@ ij_formatter_off_tag = @formatter:off ij_formatter_on_tag = @formatter:on ij_formatter_tags_enabled = false ij_smart_tabs = false -ij_visual_guides = 300 +ij_visual_guides = 80, 120 ij_wrap_on_typing = true [*.css] @@ -280,17 +280,17 @@ ij_javascript_while_brace_force = always ij_javascript_while_on_new_line = false ij_javascript_wrap_comments = false -[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}] +[{*.ctp, *.hphp, *.inc, *.module, *.php, *.php4, *.php5, *.phtml}] indent_style = tab ij_continuation_indent_size = 4 ij_smart_tabs = true ij_wrap_on_typing = false -ij_php_align_assignments = false +ij_php_align_assignments = true ij_php_align_class_constants = false ij_php_align_group_field_declarations = false ij_php_align_inline_comments = false -ij_php_align_key_value_pairs = false -ij_php_align_multiline_array_initializer_expression = false +ij_php_align_key_value_pairs = true +ij_php_align_multiline_array_initializer_expression = true ij_php_align_multiline_binary_operation = false ij_php_align_multiline_chained_methods = false ij_php_align_multiline_extends_list = false From e32e275f40691c1701b9319fe4e63ca442074a84 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 29 Jun 2021 16:45:34 +0200 Subject: [PATCH 02/10] :art: Align dataprovider elements --- test/application/UtilsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/application/UtilsTest.php b/test/application/UtilsTest.php index 1c43a2380..b90033b4d 100644 --- a/test/application/UtilsTest.php +++ b/test/application/UtilsTest.php @@ -443,10 +443,10 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase { return [ '123 int value' => ['123', 123], - '-1 no limit' => ['-1', -1], - '56k' => ['56k', 56 * 1024], - '512M' => ['512M', 512 * 1024 * 1024], - '2G' => ['2G', 2 * 1024 * 1024 * 1024], + '-1 no limit' => ['-1', -1], + '56k' => ['56k', 56 * 1024], + '512M' => ['512M', 512 * 1024 * 1024], + '2G' => ['2G', 2 * 1024 * 1024 * 1024], ]; } } From ad9726b64c5f958c09f4320174e161cd961c3985 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Wed, 30 Jun 2021 10:24:19 +0200 Subject: [PATCH 03/10] :wrench: .editorConfig : restore old ij_visual_guides value Was overwritten by mistake in 19505649 --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 5a38344ce..6991f9aad 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,7 +13,7 @@ ij_formatter_off_tag = @formatter:off ij_formatter_on_tag = @formatter:on ij_formatter_tags_enabled = false ij_smart_tabs = false -ij_visual_guides = 80, 120 +ij_visual_guides = 300 ij_wrap_on_typing = true [*.css] From 8cf75f826f25cb19cf34aefca23aafde5c9fe85d Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 1 Jul 2021 15:30:33 +0200 Subject: [PATCH 04/10] :hammer: updateLicenses : add logs and replace rm -f by unlink() --- .make/license/updateLicenses.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.make/license/updateLicenses.php b/.make/license/updateLicenses.php index 706378247..7df2fe3cb 100644 --- a/.make/license/updateLicenses.php +++ b/.make/license/updateLicenses.php @@ -73,28 +73,34 @@ function get_license_nodes($file_path) $licenses = iterator_to_array($licenseList); usort($licenses, 'sort_by_product'); + return $licenses; } $old_licenses = get_license_nodes($xmlFilePath); //generate file with updated licenses +echo "- Generating licences..."; $generated_license_file_path = __DIR__."/provfile.xml"; -exec("bash " . __DIR__ . "/gen-community-license.sh $iTopFolder > ". $generated_license_file_path); +exec("bash ".__DIR__."/gen-community-license.sh $iTopFolder > ".$generated_license_file_path); +echo "OK!\n"; + +echo "- Get licenses nodes..."; $new_licenses = get_license_nodes($generated_license_file_path); -exec("rm -f ". $generated_license_file_path); +unlink($generated_license_file_path); foreach ($old_licenses as $b) { $aProductNode = get_product_node($b); - if (get_scope($aProductNode) !== "lib" && get_scope($aProductNode) !== "datamodels" ) - { + if (get_scope($aProductNode) !== "lib" && get_scope($aProductNode) !== "datamodels") { $new_licenses[] = $b; } } usort($new_licenses, 'sort_by_product'); +echo "OK!\n"; +echo "- Overwritting Combodo license file..."; $new_dom = new DOMDocument("1.0"); $new_dom->formatOutput = true; $root = $new_dom->createElement("licenses"); @@ -105,4 +111,5 @@ foreach ($new_licenses as $b) { $root->appendChild($new_dom->importNode($b,true)); } -$new_dom->save($xmlFilePath); \ No newline at end of file +$new_dom->save($xmlFilePath); +echo "OK!\n"; \ No newline at end of file From 3694108f42e6c2fa884061e9c852688fa539d5d1 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 1 Jul 2021 17:08:43 +0200 Subject: [PATCH 05/10] =?UTF-8?q?N=C2=B03870=20updateLicenses=20:=20fix=20?= =?UTF-8?q?generating=20wrong=20product=20names=20on=20Windows=20Was=20inc?= =?UTF-8?q?luding=20paths=20fragments.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example : C:\Dev\wamp64\www\itop-dev\.make\license/../..//datamodels/2.x/authent-cas/vendor/apereo/phpcas Instead of : apereo/phpcas --- .make/license/updateLicenses.php | 49 ++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/.make/license/updateLicenses.php b/.make/license/updateLicenses.php index 7df2fe3cb..7531aa003 100644 --- a/.make/license/updateLicenses.php +++ b/.make/license/updateLicenses.php @@ -10,10 +10,6 @@ * `curl -L -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe` * this is a Windows port : https://stedolan.github.io/jq/ * - * Known bug on Windows : - * Licenses added from Composer contains a path in the product node (N°3870) - * `C:\Dev\wamp64\www\itop-dev\.make\license/../..//lib/symfony/console` - * * Licenses sources : * * `composer licenses --format json` (see https://getcomposer.org/doc/03-cli.md#licenses) * * keep every existing nodes with `/licenses/license[11]/product/@scope` not in ['lib', 'datamodels'] @@ -70,18 +66,47 @@ function get_license_nodes($file_path) $xp = new DOMXPath($dom); $licenseList = $xp->query('/licenses/license'); - $licenses = iterator_to_array($licenseList); + $licenses = iterator_to_array($licenseList); usort($licenses, 'sort_by_product'); return $licenses; } +/** @noinspection SuspiciousAssignmentsInspection */ +function fix_product_name(DOMNode &$oProductNode) +{ + $sProductNameOrig = $oProductNode->nodeValue; + + // sample : `C:\Dev\wamp64\www\itop-27\.make\license/../..//lib/symfony/polyfill-ctype` + $sProductNameFixed = remove_dir_from_string($sProductNameOrig, 'lib/'); + + // sample : `C:\Dev\wamp64\www\itop-27\.make\license/../..//datamodels/2.x/authent-cas/vendor/apereo/phpcas` + $sProductNameFixed = remove_dir_from_string($sProductNameFixed, 'vendor/'); + + $oProductNode->nodeValue = $sProductNameFixed; +} + +function remove_dir_from_string($sString, $sNeedle) +{ + if (strpos($sString, $sNeedle) === false) { + return $sString; + } + + $sStringTmp = strstr($sString, $sNeedle); + $sStringFixed = str_replace($sNeedle, '', $sStringTmp); + + // DEBUG trace O:) +// echo "$sNeedle = $sString => $sStringFixed\n"; + + return $sStringFixed; +} + $old_licenses = get_license_nodes($xmlFilePath); //generate file with updated licenses -echo "- Generating licences..."; $generated_license_file_path = __DIR__."/provfile.xml"; +echo "- Generating licences..."; exec("bash ".__DIR__."/gen-community-license.sh $iTopFolder > ".$generated_license_file_path); echo "OK!\n"; @@ -107,8 +132,16 @@ $root = $new_dom->createElement("licenses"); $new_dom->appendChild($root); foreach ($new_licenses as $b) { - $node = $new_dom->importNode($b,true); - $root->appendChild($new_dom->importNode($b,true)); + $node = $new_dom->importNode($b, true); + + // N°3870 fix when running script in Windows + // fix should be in gen-community-license.sh but it is easier to do it here ! + if (strncasecmp(PHP_OS, 'WIN', 3) === 0) { + $oProductNodeOrig = get_product_node($node); + fix_product_name($oProductNodeOrig); + } + + $root->appendChild($node); } $new_dom->save($xmlFilePath); From d90b1a3d821f094466994cf02d7e3395779e783e Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 2 Jul 2021 09:26:03 +0200 Subject: [PATCH 06/10] =?UTF-8?q?:bug:=20N=C2=B04020=20Fix=20syntax=20erro?= =?UTF-8?q?r=20for=20PHP=20<=207.1=20`syntax=20error,=20unexpected=20'cons?= =?UTF-8?q?t'=20(T=5FCONST),=20expecting=20variable=20(T=5FVARIABLE)=20in?= =?UTF-8?q?=20/var/www/itop274/setup/compiler.class.inc.php=20on=20line=20?= =?UTF-8?q?61`=20Was=20added=20in=201059befa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/compiler.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 225d4c9cf..973c49e2f 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -58,7 +58,7 @@ class MFCompiler * @var string * @since 2.7.5 3.0.0 N°4020 */ - public const REBUILD_HKEYS_NEVER= APPROOT.'data/.setup-rebuild-hkeys-never'; + const REBUILD_HKEYS_NEVER = APPROOT.'data/.setup-rebuild-hkeys-never'; /** @var \ModelFactory */ protected $oFactory; From 4748717e50e3726708cf6e3f61a1cd5d9b589eb7 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 2 Jul 2021 10:10:35 +0200 Subject: [PATCH 07/10] =?UTF-8?q?N=C2=B04126=20Improve=20max=5Fallowed=5Fp?= =?UTF-8?q?acket=20checks=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/setuputils.class.inc.php | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index d96bf51f5..8aef08e50 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -1184,39 +1184,33 @@ EOF $aResult['checks'][] = new CheckResult(CheckResult::INFO, "Info - User privileges: ".($oDBSource->GetRawPrivileges())); $bHasDbVersionRequired = self::CheckDbServerVersion($aResult, $oDBSource); - if (!$bHasDbVersionRequired) - { + if (!$bHasDbVersionRequired) { return $aResult; } // Check some server variables - $iMaxAllowedPacket = $oDBSource->GetServerVariable('max_allowed_packet'); - $iMaxUploadSize = utils::ConvertToBytes(ini_get('upload_max_filesize')); + $iMaxAllowedPacket = $oDBSource->GetServerVariable('max_allowed_packet'); + $sMaxAllowedPacketFriendly = utils::BytesToFriendlyFormat($iMaxAllowedPacket); + $iMaxUploadSize = utils::ConvertToBytes(ini_get('upload_max_filesize')); + $sMaxUploadSizeFriendly = utils::BytesToFriendlyFormat($iMaxUploadSize); if ($iMaxAllowedPacket >= (500 + $iMaxUploadSize)) // Allow some space for the query + the file to upload { - $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_allowed_packet ($iMaxAllowedPacket) is big enough compared to upload_max_filesize ($iMaxUploadSize)."); - } - else if($iMaxAllowedPacket < $iMaxUploadSize) - { - $aResult['checks'][] = new CheckResult(CheckResult::WARNING, "MySQL server's max_allowed_packet ($iMaxAllowedPacket) is not big enough. Please, consider setting it to at least ".(500 + $iMaxUploadSize)."."); + $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly)."); + } else if ($iMaxAllowedPacket < $iMaxUploadSize) { + $aResult['checks'][] = new CheckResult(CheckResult::WARNING, "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is not big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly). Please, consider setting it to at least $sMaxUploadSizeFriendly + 500."); } $iMaxConnections = $oDBSource->GetServerVariable('max_connections'); - if ($iMaxConnections < 5) - { + if ($iMaxConnections < 5) { $aResult['checks'][] = new CheckResult(CheckResult::WARNING, "MySQL server's max_connections ($iMaxConnections) is not enough. Please, consider setting it to at least 5."); - } - else - { + } else { $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_connections is set to $iMaxConnections."); } - try - { + try { $aResult['databases'] = $oDBSource->ListDB(); } - catch(Exception $e) - { + catch (Exception $e) { $aResult['databases'] = null; } } From a48ebfefba81a0cf44c49432ba75cef6fccb27ce Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Mon, 5 Jul 2021 08:42:16 +0200 Subject: [PATCH 08/10] =?UTF-8?q?N=C2=B04126=20Change=20max=5Fallowed=5Fpa?= =?UTF-8?q?cket=20error=20message=20Thanks=20@Molkobain=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/setuputils.class.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 8aef08e50..50bee123d 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -1197,7 +1197,11 @@ EOF { $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly)."); } else if ($iMaxAllowedPacket < $iMaxUploadSize) { - $aResult['checks'][] = new CheckResult(CheckResult::WARNING, "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is not big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly). Please, consider setting it to at least $sMaxUploadSizeFriendly + 500."); + $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; + $sAttachmentsVarsWikiPageUrl = 'https://wiki.openitop.org/doku.php?id='.$sWikiVersion.':install:php_and_mysql_configuration#attachments_upload'; + + $aResult['checks'][] = new CheckResult(CheckResult::WARNING, + "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is not big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly), whereas it should has a greater value. Consider increasing its value of at least 500KB. See the documentation for details."); } $iMaxConnections = $oDBSource->GetServerVariable('max_connections'); From 9aead898e22961459784dcabf2920f17abe2ac0f Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Mon, 5 Jul 2021 12:26:54 +0200 Subject: [PATCH 09/10] Fix Wiki URL to use iTop Hub instead of wiki.openitop Thanks @Molkobain and @Hipska ! --- setup/setuputils.class.inc.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 50bee123d..9d7a3c3f6 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -923,8 +923,8 @@ class SetupUtils $oPage, $bIsItopInstall, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $bTlsEnabled, $sTlsCA, $sNewDBName = '' ) { - $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; - $sMysqlTlsWikiPageUrl = 'https://wiki.openitop.org/doku.php?id='.$sWikiVersion.':install:php_and_mysql_tls'; + $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; + $sMysqlTlsWikiPageUrl = 'https://www.itophub.io/wiki/page?id='.$sWikiVersion.':install:php_and_mysql_tls'; $oPage->add(''); $oPage->add('
Database Server Connection'); @@ -933,13 +933,15 @@ class SetupUtils //-- DB connection params $oPage->add(''); $oPage->add('Server Name:E.g. "localhost", "dbserver.mycompany.com" or "192.142.10.23"'); - $oPage->add('Login:The account must have the following privileges on the database: SELECT, INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, CREATE VIEW, SHOW VIEW, LOCK TABLE, SUPER, TRIGGER'); + $oPage->add('Login:The account must have the following privileges on the database: SELECT, INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, CREATE VIEW, SHOW VIEW, LOCK TABLE, SUPER, TRIGGER'); $oPage->add('Password:'); $oPage->add(''); //-- TLS params (N°1260) $sTlsEnabledChecked = $bTlsEnabled ? ' checked' : ''; - $sTlsCaDisabled = $bTlsEnabled ? '' : ' disabled'; + $sTlsCaDisabled = $bTlsEnabled ? '' : ' disabled'; $oPage->add(''); $oPage->add(''); $oPage->add('Before configuring MySQL with TLS encryption, read the documentation on Combodo\'s Wiki'); @@ -1198,7 +1200,8 @@ EOF $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly)."); } else if ($iMaxAllowedPacket < $iMaxUploadSize) { $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; - $sAttachmentsVarsWikiPageUrl = 'https://wiki.openitop.org/doku.php?id='.$sWikiVersion.':install:php_and_mysql_configuration#attachments_upload'; + $sAttachmentsVarsWikiPageUrl = 'https://www.itophub.io/wiki/page?id='.$sWikiVersion + .':install:php_and_mysql_configuration#attachments_upload'; $aResult['checks'][] = new CheckResult(CheckResult::WARNING, "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is not big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly), whereas it should has a greater value. Consider increasing its value of at least 500KB. See the documentation for details."); From 69ad10785b791a594387fd5b4ba0d434ec064480 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Mon, 5 Jul 2021 12:33:56 +0200 Subject: [PATCH 10/10] :wrench: .editorConfig : disable PHP variables alignement Still enabled for key/value pairs though ! Example in \UtilsTest::ConvertToBytesProvider --- .editorconfig | 2 +- setup/setuputils.class.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 6991f9aad..4eb414385 100644 --- a/.editorconfig +++ b/.editorconfig @@ -285,7 +285,7 @@ indent_style = tab ij_continuation_indent_size = 4 ij_smart_tabs = true ij_wrap_on_typing = false -ij_php_align_assignments = true +ij_php_align_assignments = false ij_php_align_class_constants = false ij_php_align_group_field_declarations = false ij_php_align_inline_comments = false diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 9d7a3c3f6..565df2456 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -923,7 +923,7 @@ class SetupUtils $oPage, $bIsItopInstall, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $bTlsEnabled, $sTlsCA, $sNewDBName = '' ) { - $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; + $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; $sMysqlTlsWikiPageUrl = 'https://www.itophub.io/wiki/page?id='.$sWikiVersion.':install:php_and_mysql_tls'; $oPage->add('');