pluginsGLPI / ocsinventoryng

Plugin ocsinventoryng for GLPI
GNU General Public License v2.0
68 stars 52 forks source link

Impossible install Ocs Module Glpi 10 #322

Open hakihosting opened 2 years ago

hakihosting commented 2 years ago

Traitement terminé. (0 seconde)

For bug reports, you can open an issue here, provide us :

hakihosting commented 2 years ago

Some news ?

hakihosting commented 2 years ago

Help

tsmr commented 2 years ago

Please give us the source version of the plugin & the complete trace into sql-errors & php-errors

schoubi commented 2 years ago

hi,

I just stumbled upon it :

https://github.com/pluginsGLPI/ocsinventoryng/blob/ec4dfabed9bfd8ac587a3c2efb4536f09f3fe7aa/hook.php#L2246-L2249

should be :


      $query = "INSERT INTO `glpi_notificationtemplates`
                VALUES (NULL, 0, 'Computers not imported', 'PluginOcsinventoryngNotimportedcomputer',
                        NOW(), NULL,
                        NOW());";
tsmr commented 2 years ago

what is your glpi_notificationtemplates structure ?

schoubi commented 2 years ago

MariaDB [glpi]> describe glpi_notificationtemplates;
+---------------+------------------+------+-----+---------+----------------+
| Field         | Type             | Null | Key | Default | Extra          |
+---------------+------------------+------+-----+---------+----------------+
| date_creation | timestamp        | YES  | MUL | NULL    |                |
| id            | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name          | varchar(255)     | YES  | MUL | NULL    |                |
| itemtype      | varchar(100)     | NO   | MUL | NULL    |                |
| date_mod      | timestamp        | YES  | MUL | NULL    |                |
| comment       | mediumtext       | YES  |     | NULL    |                |
| css           | mediumtext       | YES  |     | NULL    |                |
+---------------+------------------+------+-----+---------+----------------+
7 rows in set (0.001 sec)
tsmr commented 2 years ago

In fact your table doesn't respect order of fields of GLPI table

CREATE TABLE glpi_notificationtemplates ( id int unsigned NOT NULL AUTO_INCREMENT, name varchar(255) DEFAULT NULL, itemtype varchar(100) NOT NULL, date_mod timestamp NULL DEFAULT NULL, comment text, css text, date_creation timestamp NULL DEFAULT NULL, PRIMARY KEY (id), KEY itemtype (itemtype), KEY date_mod (date_mod), KEY name (name), KEY date_creation (date_creation) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

b-o-r-i-s975 commented 2 years ago

Hello, I had the same problem. I have the same fieldorder with date_creation in first place. It seams to years (using GLPI from 2008) of GLPI update procedures does have other field orders, i exported, dropped the table, created it with the "new order" and imported all entries to get it work (only the glpi_notificationtemplates table) but why don't you use in insert the names so that the order does not matter? It would make the OCS plugin more stable. A few lines later there i the INSERT INTO `glpi_notificationtemplatetranslations'. Also without field names. I did not needed to change the translation table, only the template table, but I hope you do any insert with label name. Maybe there are because of this all the error from other cases....

for line 2246 I would change INSERT INTO... to: INSERT INTO glpi_notificationtemplates (id, name, itemtype, date_mod, comment, css,date_creation, )

for line 2252: INSERT INTO glpi_notificationtemplatetranslations (id, notificationtemplates_id, language, subject, content_text, content_html)

I did not dig into other INSERT commands, maybe there is more...

best regards, Boris.

joaoarquimedes commented 2 months ago

If you are upgrading GLPI from version 9.x to 10.x, adjust the column sequence in the glpi_notificationtemplates table:

ALTER TABLE glpi_notificationtemplates MODIFY COLUMN id int(10) unsigned NOT NULL AUTO_INCREMENT FIRST;
ALTER TABLE glpi_notificationtemplates MODIFY COLUMN name varchar(255) AFTER id;
ALTER TABLE glpi_notificationtemplates MODIFY COLUMN itemtype varchar(100) NOT NULL AFTER name;
ALTER TABLE glpi_notificationtemplates MODIFY COLUMN date_mod timestamp AFTER itemtype;
ALTER TABLE glpi_notificationtemplates MODIFY COLUMN comment text AFTER date_mod;
ALTER TABLE glpi_notificationtemplates MODIFY COLUMN css text AFTER comment;
ALTER TABLE glpi_notificationtemplates MODIFY COLUMN date_creation timestamp AFTER css;