From b188047eb8ac7e4e5a9806ec08820a257a0527b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Wed, 10 Nov 2021 10:18:13 +0100 Subject: [PATCH 01/12] Permit installation on GLPI 10.0.x --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index 0484044..ee181f6 100644 --- a/setup.php +++ b/setup.php @@ -33,7 +33,7 @@ // Minimal GLPI version, inclusive define("PLUGIN_MANTIS_MIN_GLPI", "9.5"); // Maximum GLPI version, exclusive -define("PLUGIN_MANTIS_MAX_GLPI", "9.6"); +define("PLUGIN_MANTIS_MAX_GLPI", "10.0.99"); /** * function to initialize the plugin From 4d68d5811b6da44e586b4c804874536acdb5fdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 15 Nov 2021 15:12:01 +0100 Subject: [PATCH 02/12] Replace deprecated usage of Toolbox::decrypt() --- inc/config.class.php | 8 +++++++- setup.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 01568c1..86a63ac 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -296,11 +296,17 @@ static function install(Migration $migration) { $config = new self(); $config->getFromDB(1); if (!empty($config->fields['pwd'])) { + $key = new GLPIKey(); $migration->addPostQuery( $DB->buildUpdate( 'glpi_plugin_mantis_configs', [ - 'pwd' => Toolbox::sodiumEncrypt(Toolbox::decrypt($config->fields['pwd'])) + 'pwd' => Toolbox::sodiumEncrypt( + $key->decryptUsingLegacyKey( + $config->fields['pwd'], + $key->getLegacyKey() + ) + ) ], [ 'id' => 1, diff --git a/setup.php b/setup.php index ee181f6..93a6df5 100644 --- a/setup.php +++ b/setup.php @@ -31,7 +31,7 @@ define("PLUGIN_MANTIS_VERSION", "4.4.1"); // Minimal GLPI version, inclusive -define("PLUGIN_MANTIS_MIN_GLPI", "9.5"); +define("PLUGIN_MANTIS_MIN_GLPI", "10.0.0"); // Maximum GLPI version, exclusive define("PLUGIN_MANTIS_MAX_GLPI", "10.0.99"); From 909edbe18ea2e936fb83ec94eba04ac833bf947a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Fri, 3 Dec 2021 08:56:59 +0100 Subject: [PATCH 03/12] Replace deprecated usages of (en|de)crypt methods; fix password escaping --- ajax/ajax.php | 2 +- front/config.form.php | 5 +++++ inc/config.class.php | 13 ++++--------- inc/mantis.class.php | 2 +- inc/mantisws.class.php | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ajax/ajax.php b/ajax/ajax.php index 4a30e16..1903831 100644 --- a/ajax/ajax.php +++ b/ajax/ajax.php @@ -90,7 +90,7 @@ $ws->getConnexion($_POST['host'], $_POST['url'], $_POST['login'], - Toolbox::sodiumDecrypt($_POST['pwd'])); + (new GLPIKey())->decrypt($_POST['pwd'])); $result = $ws->getStateMantis(); if (! $result) { diff --git a/front/config.form.php b/front/config.form.php index 7f5053e..06993e0 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -42,6 +42,11 @@ $PluginMantisConfig = new PluginMantisConfig(); if (isset($_POST["update"])) { + if (array_key_exists('pwd', $_POST)) { + // Password must not be altered, it will be encrypted and never displayed, so sanitize is not necessary. + $_POST['pwd'] = $_UPOST['pwd']; + } + $PluginMantisConfig->check($_POST["id"], UPDATE); $PluginMantisConfig->update($_POST); Html::back(); diff --git a/inc/config.class.php b/inc/config.class.php index 86a63ac..116d0c4 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -55,8 +55,8 @@ static function getTypeName($nb = 0) { **/ function prepareInputForUpdate($input) { - if (isset($input["pwd"]) AND !empty($input["pwd"])) { - $input["pwd"] = Toolbox::sodiumEncrypt(stripslashes($input["pwd"])); + if (isset($input["pwd"]) && !empty($input["pwd"])) { + $input["pwd"] = (new GLPIKey())->encrypt($input["pwd"]); } return $input; } @@ -122,7 +122,7 @@ function showForm($ID, $options = []) { echo ""; echo "" . __("MantisBT user password", "mantis") . ""; echo ""; + value='" . Html::entities_deep((new GLPIKey())->decrypt($this->fields["pwd"])) . "' />"; echo ""; echo ""; @@ -301,12 +301,7 @@ static function install(Migration $migration) { $DB->buildUpdate( 'glpi_plugin_mantis_configs', [ - 'pwd' => Toolbox::sodiumEncrypt( - $key->decryptUsingLegacyKey( - $config->fields['pwd'], - $key->getLegacyKey() - ) - ) + 'pwd' => $key->encrypt($key->decryptUsingLegacyKey($config->fields['pwd'])) ], [ 'id' => 1, diff --git a/inc/mantis.class.php b/inc/mantis.class.php index 99da413..7054cf9 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -497,7 +497,7 @@ public function showForm($item) { if ($ws->testConnectionWS($conf->getField('host'), $conf->getField('url'), $conf->getField('login'), - Toolbox::sodiumDecrypt($conf->getField('pwd')))) { + (new GLPIKey())->decrypt($conf->getField('pwd')))) { if ($item->fields['status'] == $conf->fields['neutralize_escalation'] || $item->fields['status'] > $conf->fields['neutralize_escalation']) { diff --git a/inc/mantisws.class.php b/inc/mantisws.class.php index b43fa52..5f33ab5 100644 --- a/inc/mantisws.class.php +++ b/inc/mantisws.class.php @@ -68,7 +68,7 @@ function initializeConnection() { $this->_host = $conf->fields["host"]; $this->_url = $conf->fields["url"]; $this->_login = $conf->fields["login"]; - $this->_password = Toolbox::sodiumDecrypt($conf->fields["pwd"]); + $this->_password = (new GLPIKey())->decrypt($conf->fields["pwd"]); $this->_client = new SoapClient($this->_host . "/" . $this->_url, self::getOptionsStreamContext()); return true; From b9e5446793075708d04109ea30f877b5e74156c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Fri, 3 Dec 2021 15:17:03 +0100 Subject: [PATCH 04/12] Fix showForm() signature --- inc/mantis.class.php | 4 ++-- inc/profile.class.php | 20 +++++--------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/inc/mantis.class.php b/inc/mantis.class.php index 7054cf9..680c076 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -73,7 +73,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem if (Session::haveRightsOr('plugin_mantis_use', [READ, UPDATE])) { $PluginMantisMantis = new self(); - $PluginMantisMantis->showForm($item); + $PluginMantisMantis->showFormForItilItem($item); } else { echo "


\"warning\"

"; @@ -484,7 +484,7 @@ private static function getInfoSolved($list_ticket_mantis) { * * @param $item */ - public function showForm($item) { + public function showFormForItilItem($item) { global $CFG_GLPI; $ws = new PluginMantisMantisws(); diff --git a/inc/profile.class.php b/inc/profile.class.php index 9153bf5..efca84c 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -106,35 +106,25 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem } - /** - * Show profile form - * - * @param $items_id integer id of the profile - * @param $target value url of target - * - * @return nothing - **/ - function showForm($profiles_id = 0, $openform = true, $closeform = true) { + function showForm($ID, array $options = []) { echo "
"; - if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) - && $openform) { + if ($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) { $profile = new Profile(); echo "
"; } $profile = new Profile(); - $profile->getFromDB($profiles_id); + $profile->getFromDB($ID); $profile->displayRightsChoiceMatrix($this->getAllRights(), ['canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')]); - if ($canedit - && $closeform) { + if ($canedit) { echo "
"; - echo Html::hidden('id', ['value' => $profiles_id]); + echo Html::hidden('id', ['value' => $ID]); echo Html::submit(_sx('button', 'Save'), ['name' => 'update']); echo "
\n"; Html::closeForm(); From 0a5371752f731869d9f787301907ad105c8cbe06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 6 Dec 2021 12:20:23 +0100 Subject: [PATCH 05/12] Use same PHP minimal version as GLPI core; upgrade build libs --- composer.json | 4 +- composer.lock | 618 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 556 insertions(+), 66 deletions(-) diff --git a/composer.json b/composer.json index 3638ad6..80f27e8 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": "^7.2" + "php": ">=7.4" }, "require-dev": { "glpi-project/tools": "^0.4" @@ -8,7 +8,7 @@ "config": { "optimize-autoloader": true, "platform": { - "php": "7.2.0" + "php": "7.4.0" }, "sort-packages": true } diff --git a/composer.lock b/composer.lock index e7a6c4e..9dbff32 100644 --- a/composer.lock +++ b/composer.lock @@ -4,25 +4,26 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8354308e8805d3f53d35251aac6a4525", + "content-hash": "fc83e1062054dc8c9ba6b4c2ba423677", "packages": [], "packages-dev": [ { "name": "glpi-project/tools", - "version": "0.4.2", + "version": "0.4.5", "source": { "type": "git", "url": "https://github.com/glpi-project/tools.git", - "reference": "34369dd85cc99c18c3b8cf441bba11ec32173f2d" + "reference": "55ffa6566813d3c40d621892713ef63614820c79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/34369dd85cc99c18c3b8cf441bba11ec32173f2d", - "reference": "34369dd85cc99c18c3b8cf441bba11ec32173f2d", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/55ffa6566813d3c40d621892713ef63614820c79", + "reference": "55ffa6566813d3c40d621892713ef63614820c79", "shasum": "" }, "require": { - "symfony/console": "^4.4 || ^5.0" + "symfony/console": "^4.4 || ^5.0", + "twig/twig": "^3.3" }, "bin": [ "bin/extract-locales", @@ -57,24 +58,24 @@ "issues": "https://github.com/glpi-project/tools/issues", "source": "https://github.com/glpi-project/tools" }, - "time": "2022-01-28T13:44:12+00:00" + "time": "2022-04-20T06:57:59+00:00" }, { "name": "psr/container", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", "shasum": "" }, "require": { - "php": ">=7.2.0" + "php": ">=7.4.0" }, "type": "library", "autoload": { @@ -103,49 +104,52 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.1" + "source": "https://github.com/php-fig/container/tree/1.1.2" }, - "time": "2021-03-05T17:36:06+00:00" + "time": "2021-11-05T16:50:12+00:00" }, { "name": "symfony/console", - "version": "v4.4.37", + "version": "v5.4.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0259f01dbf9d77badddbbf4c2abb681f24c9cac6" + "reference": "900275254f0a1a2afff1ab0e11abd5587a10e1d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0259f01dbf9d77badddbbf4c2abb681f24c9cac6", - "reference": "0259f01dbf9d77badddbbf4c2abb681f24c9cac6", + "url": "https://api.github.com/repos/symfony/console/zipball/900275254f0a1a2afff1ab0e11abd5587a10e1d6", + "reference": "900275254f0a1a2afff1ab0e11abd5587a10e1d6", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2" + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" }, "conflict": { "psr/log": ">=3", - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3|>=5", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", "symfony/lock": "<4.4", - "symfony/process": "<3.3" + "symfony/process": "<4.4" }, "provide": { "psr/log-implementation": "1.0|2.0" }, "require-dev": { "psr/log": "^1|^2", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^4.3|^5.0" + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -178,8 +182,244 @@ ], "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.4.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-03-31T17:09:19+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:53:40+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "30885182c981ab175d4d034db0f6f469898070ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-20T20:35:02+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], "support": { - "source": "https://github.com/symfony/console/tree/v4.4.37" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" }, "funding": [ { @@ -195,11 +435,95 @@ "type": "tidelift" } ], - "time": "2022-01-26T16:15:26+00:00" + "time": "2021-11-23T21:10:46+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -231,12 +555,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -262,7 +586,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" }, "funding": [ { @@ -282,7 +606,7 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -308,12 +632,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -341,7 +665,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.25.0" }, "funding": [ { @@ -361,16 +685,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", "shasum": "" }, "require": { @@ -387,12 +711,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -424,7 +748,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" }, "funding": [ { @@ -440,25 +764,29 @@ "type": "tidelift" } ], - "time": "2021-09-13T13:58:33+00:00" + "time": "2022-03-04T08:16:47+00:00" }, { "name": "symfony/service-contracts", - "version": "v1.1.11", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "633df678bec3452e04a7b0337c9bcfe7354124b3" + "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/633df678bec3452e04a7b0337c9bcfe7354124b3", - "reference": "633df678bec3452e04a7b0337c9bcfe7354124b3", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c", + "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c", "shasum": "" }, "require": { - "php": ">=7.1.3", - "psr/container": "^1.0" + "php": ">=7.2.5", + "psr/container": "^1.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" }, "suggest": { "symfony/service-implementation": "" @@ -466,7 +794,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.1-dev" + "dev-main": "2.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -503,7 +831,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v1.1.11" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.1" }, "funding": [ { @@ -519,7 +847,169 @@ "type": "tidelift" } ], - "time": "2021-11-04T13:32:43+00:00" + "time": "2022-03-13T20:07:29+00:00" + }, + { + "name": "symfony/string", + "version": "v5.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "92043b7d8383e48104e411bc9434b260dbeb5a10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/92043b7d8383e48104e411bc9434b260dbeb5a10", + "reference": "92043b7d8383e48104e411bc9434b260dbeb5a10", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "conflict": { + "symfony/translation-contracts": ">=3.0" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v5.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:53:40+00:00" + }, + { + "name": "twig/twig", + "version": "v3.3.10", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "8442df056c51b706793adf80a9fd363406dd3674" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/8442df056c51b706793adf80a9fd363406dd3674", + "reference": "8442df056c51b706793adf80a9fd363406dd3674", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "^1.8", + "symfony/polyfill-mbstring": "^1.3" + }, + "require-dev": { + "psr/container": "^1.0", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Twig Team", + "role": "Contributors" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "https://twig.symfony.com", + "keywords": [ + "templating" + ], + "support": { + "issues": "https://github.com/twigphp/Twig/issues", + "source": "https://github.com/twigphp/Twig/tree/v3.3.10" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2022-04-06T06:47:41+00:00" } ], "aliases": [], @@ -528,11 +1018,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2" + "php": ">=7.4" }, "platform-dev": [], "platform-overrides": { - "php": "7.2.0" + "php": "7.4.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } From 5fd21fb3d547bb307993f126633f43cc14343b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 6 Dec 2021 13:47:02 +0100 Subject: [PATCH 06/12] Remove deprecated usage of integer display width --- inc/config.class.php | 24 ++++++++++++------------ inc/mantis.class.php | 8 ++++---- inc/userpref.class.php | 18 +++++++++--------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 116d0c4..60a996b 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -245,25 +245,25 @@ static function install(Migration $migration) { if (!$DB->tableExists($table)) { $query = "CREATE TABLE `".$table."` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` int NOT NULL AUTO_INCREMENT, `host` varchar(255) NOT NULL default '', `url` varchar(255) NOT NULL default '', `login` varchar(255) NOT NULL default '', `pwd` varchar(255) NOT NULL default '', `champsUrlGlpi` varchar(100) NOT NULL default '', `champsGlpi` varchar(100) NOT NULL default '', - `enable_assign` int(3) NOT NULL default 0, - `neutralize_escalation` int(3) NOT NULL default 0, - `status_after_escalation` int(3) NOT NULL default 0, - `show_option_delete` int(3) NOT NULL default 0, - `doc_categorie` int(3) NOT NULL default 0, + `enable_assign` int NOT NULL default 0, + `neutralize_escalation` int NOT NULL default 0, + `status_after_escalation` int NOT NULL default 0, + `show_option_delete` int NOT NULL default 0, + `doc_categorie` int NOT NULL default 0, `itemType` varchar(255) NOT NULL default '', `etatMantis` varchar(100) NOT NULL default '', - `solutiontypes_id` int(11) NOT NULL DEFAULT 0, - `users_id` int(11) NOT NULL DEFAULT 0, - `check_ssl` int(1) NOT NULL DEFAULT 0, - `use_proxy` int(1) NOT NULL DEFAULT 0, - `is_password_sodium_encrypted` int(1) NOT NULL DEFAULT 1, + `solutiontypes_id` int NOT NULL DEFAULT 0, + `users_id` int NOT NULL DEFAULT 0, + `check_ssl` int NOT NULL DEFAULT 0, + `use_proxy` int NOT NULL DEFAULT 0, + `is_password_sodium_encrypted` int NOT NULL DEFAULT 1, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); @@ -309,7 +309,7 @@ static function install(Migration $migration) { ) ); } - $migration->addField($table, "is_password_sodium_encrypted", "INT(1) NOT NULL DEFAULT 1"); + $migration->addField($table, "is_password_sodium_encrypted", "INT NOT NULL DEFAULT 1"); } } diff --git a/inc/mantis.class.php b/inc/mantis.class.php index 680c076..f771f82 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -109,12 +109,12 @@ static function install(Migration $migration) { if (!$DB->tableExists($table)) { $query = "CREATE TABLE `".$table."` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `items_id` int(11) NOT NULL, - `idMantis` int(11) NOT NULL, + `id` int NOT NULL AUTO_INCREMENT, + `items_id` int NOT NULL, + `idMantis` int NOT NULL, `dateEscalade` date NOT NULL, `itemtype` varchar(255) NOT NULL, - `user` int(11) NOT NULL, + `user` int NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query) or die($DB->error()); diff --git a/inc/userpref.class.php b/inc/userpref.class.php index 4375822..12df4e7 100644 --- a/inc/userpref.class.php +++ b/inc/userpref.class.php @@ -44,15 +44,15 @@ static function install($migration) { if (!$DB->tableExists("glpi_plugin_mantis_userprefs")) { $query = "CREATE TABLE `glpi_plugin_mantis_userprefs` ( - `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, - `users_id` int(11) NOT NULL , - `followTask` int(11) NOT NULL default '0', - `followFollow` int(11) NOT NULL default '0', - `followAttachment` int(11) NOT NULL default '0', - `followTitle` int(11) NOT NULL default '0', - `followDescription` int(11) NOT NULL default '0', - `followCategorie` int(11) NOT NULL default '0', - `followLinkedItem` int(11) NOT NULL default '0', + `id` int NOT NULL PRIMARY KEY AUTO_INCREMENT, + `users_id` int NOT NULL , + `followTask` int NOT NULL default '0', + `followFollow` int NOT NULL default '0', + `followAttachment` int NOT NULL default '0', + `followTitle` int NOT NULL default '0', + `followDescription` int NOT NULL default '0', + `followCategorie` int NOT NULL default '0', + `followLinkedItem` int NOT NULL default '0', UNIQUE KEY (`users_id`))"; $DB->query($query) or die($DB->error()); } From faf827c5796c84053169064179776f8cbf275e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 6 Dec 2021 14:37:58 +0100 Subject: [PATCH 07/12] Use default GLPI charset/collation during install/update --- inc/config.class.php | 5 ++++- inc/mantis.class.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 60a996b..a936f62 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -244,6 +244,9 @@ static function install(Migration $migration) { $table = getTableForItemType(__CLASS__); if (!$DB->tableExists($table)) { + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $query = "CREATE TABLE `".$table."` ( `id` int NOT NULL AUTO_INCREMENT, `host` varchar(255) NOT NULL default '', @@ -265,7 +268,7 @@ static function install(Migration $migration) { `use_proxy` int NOT NULL DEFAULT 0, `is_password_sodium_encrypted` int NOT NULL DEFAULT 1, PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};"; $DB->query($query) or die($DB->error()); $query = "INSERT INTO `$table` (id) VALUES (1)"; diff --git a/inc/mantis.class.php b/inc/mantis.class.php index f771f82..c5012f0 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -107,6 +107,8 @@ static function install(Migration $migration) { $table = getTableForItemType(__CLASS__); if (!$DB->tableExists($table)) { + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); $query = "CREATE TABLE `".$table."` ( `id` int NOT NULL AUTO_INCREMENT, @@ -116,7 +118,7 @@ static function install(Migration $migration) { `itemtype` varchar(255) NOT NULL, `user` int NOT NULL, PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};"; $DB->query($query) or die($DB->error()); } else { From 0b3b4020d5b5953d8808530e71fa490c044c15ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 6 Dec 2021 15:23:40 +0100 Subject: [PATCH 08/12] Force database dynamic row format --- inc/config.class.php | 2 +- inc/mantis.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index a936f62..46b5598 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -268,7 +268,7 @@ static function install(Migration $migration) { `use_proxy` int NOT NULL DEFAULT 0, `is_password_sodium_encrypted` int NOT NULL DEFAULT 1, PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};"; + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->query($query) or die($DB->error()); $query = "INSERT INTO `$table` (id) VALUES (1)"; diff --git a/inc/mantis.class.php b/inc/mantis.class.php index c5012f0..1d2240f 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -118,7 +118,7 @@ static function install(Migration $migration) { `itemtype` varchar(255) NOT NULL, `user` int NOT NULL, PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};"; + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->query($query) or die($DB->error()); } else { From 02779c0e20d11a504a1ac524e6232726edb02251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 6 Dec 2021 15:49:25 +0100 Subject: [PATCH 09/12] Replace jQueryUI dialg by bootstrap modal --- inc/mantis.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/mantis.class.php b/inc/mantis.class.php index 1d2240f..736baae 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -572,12 +572,12 @@ public function displayBtnToLinkissueGlpi($item) { echo ""; echo ""; - echo ""; echo ""; - echo ""; @@ -987,7 +987,7 @@ private function getFormForDisplayInfo($item, $itemType) { if ($can_write && !$neutralize_escalation) { echo ""; echo ""; } else { echo "-"; From 46b592933cbb37cec2ba4250f6c0857a0f8d340e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Tue, 7 Dec 2021 09:41:17 +0100 Subject: [PATCH 10/12] Remove deprecated usage of integer display width --- inc/config.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 46b5598..130c813 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -280,19 +280,19 @@ static function install(Migration $migration) { } if (!$DB->fieldExists($table, 'solutiontypes_id')) { - $migration->addField($table, "solutiontypes_id", "INT( 11 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "solutiontypes_id", "INT NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'users_id')) { - $migration->addField($table, "users_id", "INT( 11 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "users_id", "INT NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'check_ssl')) { - $migration->addField($table, "check_ssl", "INT( 1 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "check_ssl", "INT NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'use_proxy')) { - $migration->addField($table, "use_proxy", "INT( 1 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "use_proxy", "INT NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'is_password_sodium_encrypted')) { From 61b19a986e3471590859ff3209506c58811fc87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Thu, 3 Feb 2022 11:47:42 +0100 Subject: [PATCH 11/12] Use default sign on primary/foreign keys --- inc/config.class.php | 17 +++++++++-------- inc/mantis.class.php | 13 +++++++------ inc/userpref.class.php | 26 ++++++++++++++++---------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 130c813..1417723 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -241,14 +241,15 @@ function showForm($ID, $options = []) { static function install(Migration $migration) { global $DB; + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = method_exists('DBConnection', 'getDefaultPrimaryKeySignOption') ? DBConnection::getDefaultPrimaryKeySignOption() : ''; + $table = getTableForItemType(__CLASS__); if (!$DB->tableExists($table)) { - $default_charset = DBConnection::getDefaultCharset(); - $default_collation = DBConnection::getDefaultCollation(); - $query = "CREATE TABLE `".$table."` ( - `id` int NOT NULL AUTO_INCREMENT, + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `host` varchar(255) NOT NULL default '', `url` varchar(255) NOT NULL default '', `login` varchar(255) NOT NULL default '', @@ -262,8 +263,8 @@ static function install(Migration $migration) { `doc_categorie` int NOT NULL default 0, `itemType` varchar(255) NOT NULL default '', `etatMantis` varchar(100) NOT NULL default '', - `solutiontypes_id` int NOT NULL DEFAULT 0, - `users_id` int NOT NULL DEFAULT 0, + `solutiontypes_id` int {$default_key_sign} NOT NULL DEFAULT 0, + `users_id` int {$default_key_sign} NOT NULL DEFAULT 0, `check_ssl` int NOT NULL DEFAULT 0, `use_proxy` int NOT NULL DEFAULT 0, `is_password_sodium_encrypted` int NOT NULL DEFAULT 1, @@ -280,11 +281,11 @@ static function install(Migration $migration) { } if (!$DB->fieldExists($table, 'solutiontypes_id')) { - $migration->addField($table, "solutiontypes_id", "INT NOT NULL DEFAULT 0"); + $migration->addField($table, "solutiontypes_id", "INT {$default_key_sign} NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'users_id')) { - $migration->addField($table, "users_id", "INT NOT NULL DEFAULT 0"); + $migration->addField($table, "users_id", "INT {$default_key_sign} NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'check_ssl')) { diff --git a/inc/mantis.class.php b/inc/mantis.class.php index 736baae..555473c 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -104,15 +104,16 @@ public static function countForItem(CommonDBTM $item) { static function install(Migration $migration) { global $DB; + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = method_exists('DBConnection', 'getDefaultPrimaryKeySignOption') ? DBConnection::getDefaultPrimaryKeySignOption() : ''; + $table = getTableForItemType(__CLASS__); if (!$DB->tableExists($table)) { - $default_charset = DBConnection::getDefaultCharset(); - $default_collation = DBConnection::getDefaultCollation(); - $query = "CREATE TABLE `".$table."` ( - `id` int NOT NULL AUTO_INCREMENT, - `items_id` int NOT NULL, + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, + `items_id` int {$default_key_sign} NOT NULL, `idMantis` int NOT NULL, `dateEscalade` date NOT NULL, `itemtype` varchar(255) NOT NULL, @@ -134,7 +135,7 @@ static function install(Migration $migration) { } if ($DB->fieldExists($table, 'idTicket') && !$DB->fieldExists($table, 'items_id')) { - $migration->changeField($table, 'idTicket', 'items_id', 'integer', []); + $migration->changeField($table, 'idTicket', 'items_id', "`items_id` int {$default_key_sign} NOT NULL", []); $migration->executeMigration(); } } diff --git a/inc/userpref.class.php b/inc/userpref.class.php index 12df4e7..66e450c 100644 --- a/inc/userpref.class.php +++ b/inc/userpref.class.php @@ -42,18 +42,24 @@ class PluginMantisUserpref extends CommonDBTM { static function install($migration) { global $DB; + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = method_exists('DBConnection', 'getDefaultPrimaryKeySignOption') ? DBConnection::getDefaultPrimaryKeySignOption() : ''; + if (!$DB->tableExists("glpi_plugin_mantis_userprefs")) { $query = "CREATE TABLE `glpi_plugin_mantis_userprefs` ( - `id` int NOT NULL PRIMARY KEY AUTO_INCREMENT, - `users_id` int NOT NULL , - `followTask` int NOT NULL default '0', - `followFollow` int NOT NULL default '0', - `followAttachment` int NOT NULL default '0', - `followTitle` int NOT NULL default '0', - `followDescription` int NOT NULL default '0', - `followCategorie` int NOT NULL default '0', - `followLinkedItem` int NOT NULL default '0', - UNIQUE KEY (`users_id`))"; + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, + `users_id` int {$default_key_sign} NOT NULL , + `followTask` int NOT NULL default '0', + `followFollow` int NOT NULL default '0', + `followAttachment` int NOT NULL default '0', + `followTitle` int NOT NULL default '0', + `followDescription` int NOT NULL default '0', + `followCategorie` int NOT NULL default '0', + `followLinkedItem` int NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY (`users_id`) + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->query($query) or die($DB->error()); } } From 15c587b405ae297d0a1b230706aa69a8507a1cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Fri, 25 Mar 2022 11:33:04 +0100 Subject: [PATCH 12/12] Drop useless check --- inc/config.class.php | 2 +- inc/mantis.class.php | 2 +- inc/userpref.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/config.class.php b/inc/config.class.php index 1417723..acb9677 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -243,7 +243,7 @@ static function install(Migration $migration) { $default_charset = DBConnection::getDefaultCharset(); $default_collation = DBConnection::getDefaultCollation(); - $default_key_sign = method_exists('DBConnection', 'getDefaultPrimaryKeySignOption') ? DBConnection::getDefaultPrimaryKeySignOption() : ''; + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); $table = getTableForItemType(__CLASS__); diff --git a/inc/mantis.class.php b/inc/mantis.class.php index 555473c..86e6124 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -106,7 +106,7 @@ static function install(Migration $migration) { $default_charset = DBConnection::getDefaultCharset(); $default_collation = DBConnection::getDefaultCollation(); - $default_key_sign = method_exists('DBConnection', 'getDefaultPrimaryKeySignOption') ? DBConnection::getDefaultPrimaryKeySignOption() : ''; + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); $table = getTableForItemType(__CLASS__); diff --git a/inc/userpref.class.php b/inc/userpref.class.php index 66e450c..868a4d5 100644 --- a/inc/userpref.class.php +++ b/inc/userpref.class.php @@ -44,7 +44,7 @@ static function install($migration) { $default_charset = DBConnection::getDefaultCharset(); $default_collation = DBConnection::getDefaultCollation(); - $default_key_sign = method_exists('DBConnection', 'getDefaultPrimaryKeySignOption') ? DBConnection::getDefaultPrimaryKeySignOption() : ''; + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); if (!$DB->tableExists("glpi_plugin_mantis_userprefs")) { $query = "CREATE TABLE `glpi_plugin_mantis_userprefs` (