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(fields): add default value to prevent SQL error #2965

Merged

Conversation

stonebuzz
Copy link
Contributor

Changes description

Prevent SQL error when user does not select value from dropdown

[2022-09-06 10:11:13] glpisqllog.ERROR: DBmysql::query() in /home/dev/GLPI/10.0-bugfixes/src/DBmysql.php line 370
  *** MySQL query error:
  SQL: INSERT INTO `glpi_plugin_fields_ticketblocfcs` (`plugin_fields_containers_id`, `nativetextfield`, `plugin_fields_customdropdownfielddropdowns_id`, `plugin_fields_plannificationfielddropdowns_id`, `items_id`) VALUES ('5', '', '1', '', '28')
  Error: Incorrect integer value: '' for column 'plugin_fields_plannificationfielddropdowns_id' at row 1
  Backtrace :
  src/DBmysql.php:1312                               
  src/CommonDBTM.php:716                             DBmysql->insert()
  src/CommonDBTM.php:1316                            CommonDBTM->addToDB()
  plugins/fields/inc/container.class.php:1070        CommonDBTM->add()
  plugins/fields/inc/container.class.php:1414        PluginFieldsContainer->updateFieldsValues()
  src/Plugin.php:1476                                PluginFieldsContainer::postItemAdd()
  src/CommonDBTM.php:1363                            Plugin::doHook()
  plugins/formcreator/inc/targetticket.class.php:943 CommonDBTM->add()
  plugins/formcreator/inc/formanswer.class.php:869   PluginFormcreatorTargetTicket->save()
  plugins/formcreator/inc/formanswer.class.php:1091  PluginFormcreatorFormAnswer->generateTarget()
  src/CommonDBTM.php:1317                            PluginFormcreatorFormAnswer->post_addItem()
  plugins/formcreator/ajax/formanswer.php:58         CommonDBTM->add()
  {"user":"2@Desktop","mem_usage":"0.272\", 8.89Mio)"} 

Checklist

Please check if your PR fulfills the following specifications:

  • Tests for the changes have been added
  • Docs have been added/updated

References

Closes #N/A

@stonebuzz stonebuzz added the bug label Sep 6, 2022
@stonebuzz stonebuzz added this to the 2.13.1 milestone Sep 6, 2022
@stonebuzz stonebuzz requested a review from btry September 6, 2022 10:17
@stonebuzz stonebuzz self-assigned this Sep 6, 2022
btry
btry previously approved these changes Sep 6, 2022
@btry btry modified the milestones: 2.13.1, 2.13.2 Sep 20, 2022
@stonebuzz stonebuzz force-pushed the fix_sql_error_when_dropdown_not_selected branch from b6edebc to f945948 Compare September 28, 2022 13:19
@btry btry merged commit bbe7d37 into pluginsGLPI:develop Oct 13, 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.

2 participants