Skip to content

Conversation

@PlaneNuts
Copy link
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes Error: SQL Warnings: 1292 #371
  • Here is a brief description of what this PR does: When loading the form to add a new injection model the DB is queried multiple times by the checkRightOnModel() function with "" as the $models_id (since no model is being selected). This throws multiple errors of
SQL Warnings: 1292: Truncated incorrect DECIMAL value: '' in query "(SELECT `itemtype` FROM `glpi_plugin_datainjection_models` WHERE `id` = '') UNION (SELECT DISTINCT `itemtype` FROM `glpi_plugin_datainjection_mappings` WHERE `models_id` = '') UNION (SELECT DISTINCT `itemtype` FROM `glpi_plugin_datainjection_infos` WHERE `models_id` = '')"

This change sets it to -1 when null in order to feed a valid value into the query.

I've confirmed that existing models still load without issue, and the error for a new model no longer appears.

Screenshots (if appropriate):

@Rom1-B Rom1-B requested review from Rom1-B and stonebuzz December 9, 2024 10:52
@stonebuzz
Copy link
Contributor

Hi @PlaneNuts

can you adapt CHANGELOG.md ?

Best regards

Co-authored-by: Stanislas <skita@teclib.com>
@stonebuzz stonebuzz self-requested a review December 10, 2024 13:23
@Rom1-B Rom1-B merged commit abe9757 into pluginsGLPI:main Dec 10, 2024
3 checks passed
@stonebuzz stonebuzz mentioned this pull request Dec 11, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: SQL Warnings: 1292

3 participants