Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(glpi_item): add default value to prevent error when field is not filled #534

Merged

Conversation

stonebuzz
Copy link
Contributor

Add default value to prevent SQL error when field glpi_item is not filled

[2022-06-08 10:15:16] glpisqllog.ERROR: DBmysql::query() in /home/stanislas/Teclib/dev/GLPI/10.0-bugfixes/src/DBmysql.php line 370
  *** MySQL query error:
  SQL: INSERT INTO `glpi_plugin_fields_ticketbloc` (`plugin_fields_containers_id`, `items_id`, `plugin_fields_customdropdownfielddropdowns_id`, `nativetextfield`, `nativedatefield`, `nativedatetimefield`, `nativeyesnofield`, `nativeuserfield`) VALUES ('5', '10', '2', 'titi', '2022-06-07', '2022-06-07 10:14:42', '1', '2')
  Error: Field 'itemtype_glpiitemfield' doesn't have a default value
  Backtrace :
  src/DBmysql.php:1312                               
  src/CommonDBTM.php:705                             DBmysql->insert()
  src/CommonDBTM.php:1297                            CommonDBTM->addToDB()
  plugins/fields/inc/container.class.php:1068        CommonDBTM->add()
  plugins/fields/inc/container.class.php:1424        PluginFieldsContainer->updateFieldsValues()
  src/Plugin.php:1454                                PluginFieldsContainer::preItemUpdate()
  src/CommonDBTM.php:1563                            Plugin::doHook()
  front/ticket.form.php:84                           CommonDBTM->update()
  {"user":"2@Desktop","mem_usage":"0.006\", 4.37Mio)"} 

Copy link
Contributor

@AdrienClairembault AdrienClairembault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar tables seems to use a null value instead of an empty string, here are two examples:

CREATE TABLE `glpi_items_devicegenerics` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `items_id` int(11) NOT NULL DEFAULT '0',
  `itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,

CREATE TABLE `glpi_items_problems` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `problems_id` int(11) NOT NULL DEFAULT '0',
  `itemtype` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,

@stonebuzz
Copy link
Contributor Author

Similar tables seems to use a null value instead of an empty string, here are two examples:

CREATE TABLE `glpi_items_devicegenerics` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `items_id` int(11) NOT NULL DEFAULT '0',
  `itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,

CREATE TABLE `glpi_items_problems` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `problems_id` int(11) NOT NULL DEFAULT '0',
  `itemtype` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,

agree with that

@cedric-anne cedric-anne added this to the 1.15.4 milestone Jun 10, 2022
@cedric-anne cedric-anne merged commit da32633 into pluginsGLPI:develop Jun 10, 2022
@cedric-anne cedric-anne modified the milestones: 1.15.4, 1.16.0 Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants