Skip to content

Commit a804e2b

Browse files
committed
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
1 parent 0c9f9be commit a804e2b

8 files changed

Lines changed: 34 additions & 31 deletions

File tree

AUTHORS.txt

100755100644
File mode changed.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"require": {
3-
"php": "^7.2"
3+
"php": ">=7.4"
44
},
55
"require-dev": {
66
"glpi-project/tools": "^0.4"
77
},
88
"config": {
99
"optimize-autoloader": true,
1010
"platform": {
11-
"php": "7.2.0"
11+
"php": "7.4.0"
1212
},
1313
"sort-packages": true
1414
}

config.php

100755100644
File mode changed.

example.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<versions>
2727
<version>
2828
<num>0.0.1</num>
29-
<compatibility>9.5</compatibility>
29+
<compatibility>~10.0.0</compatibility>
3030
</version>
3131
</versions>
3232
<langs>

front/example.php

100755100644
File mode changed.

hook.php

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ function plugin_example_MassiveActionsFieldsDisplay($options = []) {
295295
switch ($table.".".$field) {
296296
case 'glpi_plugin_example_examples.serial' :
297297
echo __("Not really specific - Just for example", 'example');
298-
//Html::autocompletionTextField($linkfield,$table,$field);
299298
// Dropdown::showYesNo($linkfield);
300299
// Need to return true if specific display
301300
return true;
@@ -471,17 +470,21 @@ function plugin_example_install() {
471470

472471
ProfileRight::addProfileRights(['example:read']);
473472

473+
$default_charset = DBConnection::getDefaultCharset();
474+
$default_collation = DBConnection::getDefaultCollation();
475+
$default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();
476+
474477
if (!$DB->tableExists("glpi_plugin_example_examples")) {
475478
$query = "CREATE TABLE `glpi_plugin_example_examples` (
476-
`id` int(11) NOT NULL auto_increment,
477-
`name` varchar(255) collate utf8_unicode_ci default NULL,
478-
`serial` varchar(255) collate utf8_unicode_ci NOT NULL,
479-
`plugin_example_dropdowns_id` int(11) NOT NULL default '0',
480-
`is_deleted` tinyint(1) NOT NULL default '0',
481-
`is_template` tinyint(1) NOT NULL default '0',
482-
`template_name` varchar(255) collate utf8_unicode_ci default NULL,
479+
`id` int {$default_key_sign} NOT NULL auto_increment,
480+
`name` varchar(255) default NULL,
481+
`serial` varchar(255) NOT NULL,
482+
`plugin_example_dropdowns_id` int NOT NULL default '0',
483+
`is_deleted` tinyint NOT NULL default '0',
484+
`is_template` tinyint NOT NULL default '0',
485+
`template_name` varchar(255) default NULL,
483486
PRIMARY KEY (`id`)
484-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
487+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
485488

486489
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
487490

@@ -496,12 +499,12 @@ function plugin_example_install() {
496499

497500
if (!$DB->tableExists("glpi_plugin_example_dropdowns")) {
498501
$query = "CREATE TABLE `glpi_plugin_example_dropdowns` (
499-
`id` int(11) NOT NULL auto_increment,
500-
`name` varchar(255) collate utf8_unicode_ci default NULL,
501-
`comment` text collate utf8_unicode_ci,
502+
`id` int {$default_key_sign} NOT NULL auto_increment,
503+
`name` varchar(255) default NULL,
504+
`comment` text,
502505
PRIMARY KEY (`id`),
503506
KEY `name` (`name`)
504-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
507+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
505508

506509
$DB->query($query) or die("error creating glpi_plugin_example_dropdowns". $DB->error());
507510

@@ -516,32 +519,32 @@ function plugin_example_install() {
516519

517520
if (!$DB->tableExists('glpi_plugin_example_devicecameras')) {
518521
$query = "CREATE TABLE `glpi_plugin_example_devicecameras` (
519-
`id` int(11) NOT NULL AUTO_INCREMENT,
520-
`designation` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
521-
`comment` text COLLATE utf8_unicode_ci,
522-
`manufacturers_id` int(11) NOT NULL DEFAULT '0',
522+
`id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
523+
`designation` varchar(255) DEFAULT NULL,
524+
`comment` text,
525+
`manufacturers_id` int {$default_key_sign} NOT NULL DEFAULT '0',
523526
PRIMARY KEY (`id`),
524527
KEY `designation` (`designation`),
525528
KEY `manufacturers_id` (`manufacturers_id`)
526-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
529+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
527530

528531
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
529532
}
530533

531534
if (!$DB->tableExists('glpi_plugin_example_items_devicecameras')) {
532535
$query = "CREATE TABLE `glpi_plugin_example_items_devicecameras` (
533-
`id` int(11) NOT NULL AUTO_INCREMENT,
534-
`items_id` int(11) NOT NULL DEFAULT '0',
535-
`itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
536-
`plugin_example_devicecameras_id` int(11) NOT NULL DEFAULT '0',
537-
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
538-
`is_dynamic` tinyint(1) NOT NULL DEFAULT '0',
536+
`id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
537+
`items_id` int {$default_key_sign} NOT NULL DEFAULT '0',
538+
`itemtype` varchar(255) DEFAULT NULL,
539+
`plugin_example_devicecameras_id` int {$default_key_sign} NOT NULL DEFAULT '0',
540+
`is_deleted` tinyint NOT NULL DEFAULT '0',
541+
`is_dynamic` tinyint NOT NULL DEFAULT '0',
539542
PRIMARY KEY (`id`),
540543
KEY `computers_id` (`items_id`),
541544
KEY `plugin_example_devicecameras_id` (`plugin_example_devicecameras_id`),
542545
KEY `is_deleted` (`is_deleted`),
543546
KEY `is_dynamic` (`is_dynamic`)
544-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
547+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
545548

546549
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
547550
}

inc/example.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function defineTabs($options = []) {
9494
return $ong;
9595
}
9696

97-
function showForm($ID, $options = []) {
97+
function showForm($ID, array $options = []) {
9898
global $CFG_GLPI;
9999

100100
$this->initForm($ID, $options);

setup.php

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
define('PLUGIN_EXAMPLE_VERSION', '0.0.1');
3434

3535
// Minimal GLPI version, inclusive
36-
define('PLUGIN_EXAMPLE_MIN_GLPI', '9.5.0');
36+
define('PLUGIN_EXAMPLE_MIN_GLPI', '10.0.0');
3737
// Maximum GLPI version, exclusive
38-
define('PLUGIN_EXAMPLE_MAX_GLPI', '9.5.99');
38+
define('PLUGIN_EXAMPLE_MAX_GLPI', '10.0.99');
3939

4040
/**
4141
* Init hooks of the plugin.

0 commit comments

Comments
 (0)