GLPI 10.0 compatibility

* Permit installation on GLPI 10.0.x
* Remove dead code referencing removed method
* Fix showForm() signature
* Use same PHP minimal version as GLPI core; upgrade build libs
* Remove deprecated usage of integer display width
* Use default GLPI charset/collation during install/update
* Force database dynamic row format
* Fix files mode
* Update compatibility in XML
* Use default sign on primary/foreign keys
This commit is contained in:
Cédric Anne 2022-04-21 10:47:05 +02:00
parent 0c9f9be88c
commit a804e2b5cc
8 changed files with 34 additions and 31 deletions

0
AUTHORS.txt Executable file → Normal file
View File

View File

@ -1,6 +1,6 @@
{ {
"require": { "require": {
"php": "^7.2" "php": ">=7.4"
}, },
"require-dev": { "require-dev": {
"glpi-project/tools": "^0.4" "glpi-project/tools": "^0.4"
@ -8,7 +8,7 @@
"config": { "config": {
"optimize-autoloader": true, "optimize-autoloader": true,
"platform": { "platform": {
"php": "7.2.0" "php": "7.4.0"
}, },
"sort-packages": true "sort-packages": true
} }

0
config.php Executable file → Normal file
View File

View File

@ -26,7 +26,7 @@
<versions> <versions>
<version> <version>
<num>0.0.1</num> <num>0.0.1</num>
<compatibility>9.5</compatibility> <compatibility>~10.0.0</compatibility>
</version> </version>
</versions> </versions>
<langs> <langs>

0
front/example.php Executable file → Normal file
View File

View File

@ -295,7 +295,6 @@ function plugin_example_MassiveActionsFieldsDisplay($options = []) {
switch ($table.".".$field) { switch ($table.".".$field) {
case 'glpi_plugin_example_examples.serial' : case 'glpi_plugin_example_examples.serial' :
echo __("Not really specific - Just for example", 'example'); echo __("Not really specific - Just for example", 'example');
//Html::autocompletionTextField($linkfield,$table,$field);
// Dropdown::showYesNo($linkfield); // Dropdown::showYesNo($linkfield);
// Need to return true if specific display // Need to return true if specific display
return true; return true;
@ -471,17 +470,21 @@ function plugin_example_install() {
ProfileRight::addProfileRights(['example:read']); ProfileRight::addProfileRights(['example:read']);
$default_charset = DBConnection::getDefaultCharset();
$default_collation = DBConnection::getDefaultCollation();
$default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();
if (!$DB->tableExists("glpi_plugin_example_examples")) { if (!$DB->tableExists("glpi_plugin_example_examples")) {
$query = "CREATE TABLE `glpi_plugin_example_examples` ( $query = "CREATE TABLE `glpi_plugin_example_examples` (
`id` int(11) NOT NULL auto_increment, `id` int {$default_key_sign} NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL, `name` varchar(255) default NULL,
`serial` varchar(255) collate utf8_unicode_ci NOT NULL, `serial` varchar(255) NOT NULL,
`plugin_example_dropdowns_id` int(11) NOT NULL default '0', `plugin_example_dropdowns_id` int NOT NULL default '0',
`is_deleted` tinyint(1) NOT NULL default '0', `is_deleted` tinyint NOT NULL default '0',
`is_template` tinyint(1) NOT NULL default '0', `is_template` tinyint NOT NULL default '0',
`template_name` varchar(255) collate utf8_unicode_ci default NULL, `template_name` varchar(255) default NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error()); $DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
@ -496,12 +499,12 @@ function plugin_example_install() {
if (!$DB->tableExists("glpi_plugin_example_dropdowns")) { if (!$DB->tableExists("glpi_plugin_example_dropdowns")) {
$query = "CREATE TABLE `glpi_plugin_example_dropdowns` ( $query = "CREATE TABLE `glpi_plugin_example_dropdowns` (
`id` int(11) NOT NULL auto_increment, `id` int {$default_key_sign} NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL, `name` varchar(255) default NULL,
`comment` text collate utf8_unicode_ci, `comment` text,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `name` (`name`) KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_dropdowns". $DB->error()); $DB->query($query) or die("error creating glpi_plugin_example_dropdowns". $DB->error());
@ -516,32 +519,32 @@ function plugin_example_install() {
if (!$DB->tableExists('glpi_plugin_example_devicecameras')) { if (!$DB->tableExists('glpi_plugin_example_devicecameras')) {
$query = "CREATE TABLE `glpi_plugin_example_devicecameras` ( $query = "CREATE TABLE `glpi_plugin_example_devicecameras` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
`designation` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `designation` varchar(255) DEFAULT NULL,
`comment` text COLLATE utf8_unicode_ci, `comment` text,
`manufacturers_id` int(11) NOT NULL DEFAULT '0', `manufacturers_id` int {$default_key_sign} NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `designation` (`designation`), KEY `designation` (`designation`),
KEY `manufacturers_id` (`manufacturers_id`) KEY `manufacturers_id` (`manufacturers_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error()); $DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
} }
if (!$DB->tableExists('glpi_plugin_example_items_devicecameras')) { if (!$DB->tableExists('glpi_plugin_example_items_devicecameras')) {
$query = "CREATE TABLE `glpi_plugin_example_items_devicecameras` ( $query = "CREATE TABLE `glpi_plugin_example_items_devicecameras` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
`items_id` int(11) NOT NULL DEFAULT '0', `items_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `itemtype` varchar(255) DEFAULT NULL,
`plugin_example_devicecameras_id` int(11) NOT NULL DEFAULT '0', `plugin_example_devicecameras_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`is_deleted` tinyint(1) NOT NULL DEFAULT '0', `is_deleted` tinyint NOT NULL DEFAULT '0',
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0', `is_dynamic` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `computers_id` (`items_id`), KEY `computers_id` (`items_id`),
KEY `plugin_example_devicecameras_id` (`plugin_example_devicecameras_id`), KEY `plugin_example_devicecameras_id` (`plugin_example_devicecameras_id`),
KEY `is_deleted` (`is_deleted`), KEY `is_deleted` (`is_deleted`),
KEY `is_dynamic` (`is_dynamic`) KEY `is_dynamic` (`is_dynamic`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error()); $DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
} }

View File

@ -94,7 +94,7 @@ class PluginExampleExample extends CommonDBTM {
return $ong; return $ong;
} }
function showForm($ID, $options = []) { function showForm($ID, array $options = []) {
global $CFG_GLPI; global $CFG_GLPI;
$this->initForm($ID, $options); $this->initForm($ID, $options);

4
setup.php Executable file → Normal file
View File

@ -33,9 +33,9 @@ use Glpi\Plugin\Hooks;
define('PLUGIN_EXAMPLE_VERSION', '0.0.1'); define('PLUGIN_EXAMPLE_VERSION', '0.0.1');
// Minimal GLPI version, inclusive // Minimal GLPI version, inclusive
define('PLUGIN_EXAMPLE_MIN_GLPI', '9.5.0'); define('PLUGIN_EXAMPLE_MIN_GLPI', '10.0.0');
// Maximum GLPI version, exclusive // Maximum GLPI version, exclusive
define('PLUGIN_EXAMPLE_MAX_GLPI', '9.5.99'); define('PLUGIN_EXAMPLE_MAX_GLPI', '10.0.99');
/** /**
* Init hooks of the plugin. * Init hooks of the plugin.