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": {
"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
}

0
config.php Executable file → Normal file
View File

View File

@ -26,7 +26,7 @@
<versions>
<version>
<num>0.0.1</num>
<compatibility>9.5</compatibility>
<compatibility>~10.0.0</compatibility>
</version>
</versions>
<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) {
case 'glpi_plugin_example_examples.serial' :
echo __("Not really specific - Just for example", 'example');
//Html::autocompletionTextField($linkfield,$table,$field);
// Dropdown::showYesNo($linkfield);
// Need to return true if specific display
return true;
@ -471,17 +470,21 @@ function plugin_example_install() {
ProfileRight::addProfileRights(['example:read']);
$default_charset = DBConnection::getDefaultCharset();
$default_collation = DBConnection::getDefaultCollation();
$default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();
if (!$DB->tableExists("glpi_plugin_example_examples")) {
$query = "CREATE TABLE `glpi_plugin_example_examples` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`serial` varchar(255) collate utf8_unicode_ci NOT NULL,
`plugin_example_dropdowns_id` int(11) NOT NULL default '0',
`is_deleted` tinyint(1) NOT NULL default '0',
`is_template` tinyint(1) NOT NULL default '0',
`template_name` varchar(255) collate utf8_unicode_ci default NULL,
`id` int {$default_key_sign} NOT NULL auto_increment,
`name` varchar(255) default NULL,
`serial` varchar(255) NOT NULL,
`plugin_example_dropdowns_id` int NOT NULL default '0',
`is_deleted` tinyint NOT NULL default '0',
`is_template` tinyint NOT NULL default '0',
`template_name` varchar(255) default NULL,
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());
@ -496,12 +499,12 @@ function plugin_example_install() {
if (!$DB->tableExists("glpi_plugin_example_dropdowns")) {
$query = "CREATE TABLE `glpi_plugin_example_dropdowns` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`comment` text collate utf8_unicode_ci,
`id` int {$default_key_sign} NOT NULL auto_increment,
`name` varchar(255) default NULL,
`comment` text,
PRIMARY KEY (`id`),
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());
@ -516,32 +519,32 @@ function plugin_example_install() {
if (!$DB->tableExists('glpi_plugin_example_devicecameras')) {
$query = "CREATE TABLE `glpi_plugin_example_devicecameras` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`designation` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`comment` text COLLATE utf8_unicode_ci,
`manufacturers_id` int(11) NOT NULL DEFAULT '0',
`id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
`designation` varchar(255) DEFAULT NULL,
`comment` text,
`manufacturers_id` int {$default_key_sign} NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `designation` (`designation`),
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());
}
if (!$DB->tableExists('glpi_plugin_example_items_devicecameras')) {
$query = "CREATE TABLE `glpi_plugin_example_items_devicecameras` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`items_id` int(11) NOT NULL DEFAULT '0',
`itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`plugin_example_devicecameras_id` int(11) NOT NULL DEFAULT '0',
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
`id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
`items_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`itemtype` varchar(255) DEFAULT NULL,
`plugin_example_devicecameras_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`is_deleted` tinyint NOT NULL DEFAULT '0',
`is_dynamic` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `computers_id` (`items_id`),
KEY `plugin_example_devicecameras_id` (`plugin_example_devicecameras_id`),
KEY `is_deleted` (`is_deleted`),
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());
}

View File

@ -94,7 +94,7 @@ class PluginExampleExample extends CommonDBTM {
return $ong;
}
function showForm($ID, $options = []) {
function showForm($ID, array $options = []) {
global $CFG_GLPI;
$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');
// Minimal GLPI version, inclusive
define('PLUGIN_EXAMPLE_MIN_GLPI', '9.5.0');
define('PLUGIN_EXAMPLE_MIN_GLPI', '10.0.0');
// 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.