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 group user import #306

Merged
merged 3 commits into from
Sep 14, 2022

Conversation

cconard96
Copy link
Contributor

Try to fix certain cases of imports such as a Group import that includes a group member field.
Commit 6974858 had broken this type of import because effectiveAddOrUpdate would receive an itemtype and items_id value which were not valid search options, but were still required for the import to work.

This patch seems to resolve this particular issue although I don't know if it will cause other issues.

@cedric-anne
Copy link
Contributor

@cconard96 Can this be fixed by #302 ?

@cconard96
Copy link
Contributor Author

@kabassanov and I saw that PR and it did not seem to fix the issue they were having.

inc/commoninjectionlib.class.php Outdated Show resolved Hide resolved
inc/commoninjectionlib.class.php Outdated Show resolved Hide resolved
@cedric-anne cedric-anne force-pushed the fix/group_user_import branch from 7c35293 to 336e4ab Compare September 6, 2022 07:21
@stonebuzz
Copy link
Contributor

stonebuzz commented Sep 9, 2022

@cconard96 does not work for me

My CSV file

user_name; group_name
user1 ; group1

Error :

[2022-09-09 08:07:25] glpisqllog.ERROR: DBmysql::query() in /home/dev/GLPI/10.0-bugfixes/src/DBmysql.php line 370
  *** MySQL query error:
  SQL: INSERT INTO `glpi_users` (`name`, `groups_id`, `entities_id`, `authtype`, `auths_id`, `is_active`, `is_deleted`, `profiles_id`, `date_creation`, `date_mod`) VALUES ('user1', 'group1', '0', '1', '0', '1', '0', '0', '2022-09-09 08:07:25', '2022-09-09 08:07:25')
  Error: Incorrect integer value: 'group1' for column 'groups_id' at row 1
  Backtrace :
  src/DBmysql.php:1312                               
  src/CommonDBTM.php:716                             DBmysql->insert()
  src/CommonDBTM.php:1316                            CommonDBTM->addToDB()
  ...injection/inc/commoninjectionlib.class.php:1549 CommonDBTM->add()
  ...injection/inc/commoninjectionlib.class.php:1453 PluginDatainjectionCommonInjectionLib->effectiveAddOrUpdate()
  ...s/datainjection/inc/userinjection.class.php:121 PluginDatainjectionCommonInjectionLib->processAddOrUpdate()
  plugins/datainjection/inc/engine.class.php:147     PluginDatainjectionUserInjection->addOrUpdateObject()
  ...datainjection/inc/clientinjection.class.php:267 PluginDatainjectionEngine->injectLine()
  ...datainjection/inc/clientinjection.class.php:219 PluginDatainjectionClientInjection::processInjection()
  ...datainjection/front/clientinjection.form.php:42 PluginDatainjectionClientInjection::showInjectionForm()
  {"user":"2@stanislas-XPS-13-9343"} 

@stonebuzz
Copy link
Contributor

group1 is well added to GLPI, but datainjection does not keep track of the ID

@kabassanov
Copy link

You must use groups_id instead of group name in the file you try to import...

@stonebuzz
Copy link
Contributor

You must use groups_id instead of group name in the file you try to import...

Even if I put the group ID, it is not added to the list

image

@kabassanov
Copy link

Well, the bug we met was related to the user insertion during a group injection. In your case, it is a group insertion during a user injection. So it could be another bug...

@stonebuzz
Copy link
Contributor

My bad, I didn't read the description correctly

@Hantiel
Copy link

Hantiel commented Sep 13, 2022

@cconard96 :fix/group_user_import - Still same issue - Groups are imported without users. Anyone tested this solution ? because I don't know if I'm doing something wrong

@kabassanov
Copy link

@Hantiel, it worked for me at least with the first commit. Will try to check with the last 2 ones...
Could you show what your csv file looks like?

@Hantiel
Copy link

Hantiel commented Sep 14, 2022

CSV
hantiel - login in GLPI
image
Mapping
image
I will very thankful for help - i need to migrate 300 group with different users / managers so any help will be unappreciated.

@kabassanov
Copy link

@Hantiel, the "issue" is that you have to use integer users_id (that GLPI previously gave to each inserted user) and not his name (login)...

@Hantiel
Copy link

Hantiel commented Sep 14, 2022

Something Like that ? Mapping without changes?
image
Still same - user / manager are not added.
Im using fix/group_user_import version

@kabassanov
Copy link

Does-it work when you try to fill a non-manager
Do you have any relevant information in php-errors.log or sql-errors.log?

@cedric-anne cedric-anne merged commit 1884516 into pluginsGLPI:develop Sep 14, 2022
@cedric-anne cedric-anne added this to the 2.12.0 milestone Sep 14, 2022
@cedric-anne
Copy link
Contributor

I merged it as it relove a regression introduced in previous versions. Remaining bugs may not be really related to this.

@Hantiel
Copy link

Hantiel commented Sep 14, 2022

I just install / copy actually develop version and same ;/

sql-error.log

[2022-09-14 13:24:24] glpisqllog.ERROR: DBmysql::query() in /var/www/html/glpi/src/DBmysql.php line 370
*** MySQL query error:
SQL: INSERT INTO glpi_groups_users (users_id, groups_id) VALUES (NULL, '139')
Error: Column 'users_id' cannot be null
Backtrace :
src/DBmysql.php:1312
src/CommonDBTM.php:705 DBmysql->insert()
src/CommonDBTM.php:1304 CommonDBTM->addToDB()
...injection/inc/commoninjectionlib.class.php:1551 CommonDBTM->add()
...injection/inc/commoninjectionlib.class.php:1496 PluginDatainjectionCommonInjectionLib->effectiveAddOrUpdate()
...s/datainjection/inc/groupinjection.class.php:84 PluginDatainjectionCommonInjectionLib->processAddOrUpdate()
plugins/datainjection/inc/engine.class.php:147 PluginDatainjectionGroupInjection->addOrUpdateObject()
...datainjection/inc/clientinjection.class.php:267 PluginDatainjectionEngine->injectLine()
...datainjection/inc/clientinjection.class.php:219 PluginDatainjectionClientInjection::processInjection()
...datainjection/front/clientinjection.form.php:42 PluginDatainjectionClientInjection::showInjectionForm()
{"user":"7@GLPI_User"}
[2022-09-14 13:24:24] glpisqllog.ERROR: DBmysql::query() in /var/www/html/glpi/src/DBmysql.php line 370
*** MySQL query error:
SQL: INSERT INTO glpi_groups_users (is_manager, users_id, groups_id) VALUES ('1', NULL, '140')
Error: Column 'users_id' cannot be null
Backtrace :
src/DBmysql.php:1312
src/CommonDBTM.php:705 DBmysql->insert()
src/CommonDBTM.php:1304 CommonDBTM->addToDB()
...injection/inc/commoninjectionlib.class.php:1551 CommonDBTM->add()
...injection/inc/commoninjectionlib.class.php:1496 PluginDatainjectionCommonInjectionLib->effectiveAddOrUpdate()
...s/datainjection/inc/groupinjection.class.php:84 PluginDatainjectionCommonInjectionLib->processAddOrUpdate()
plugins/datainjection/inc/engine.class.php:147 PluginDatainjectionGroupInjection->addOrUpdateObject()
...datainjection/inc/clientinjection.class.php:267 PluginDatainjectionEngine->injectLine()
...datainjection/inc/clientinjection.class.php:219 PluginDatainjectionClientInjection::processInjection()
...datainjection/front/clientinjection.form.php:42 PluginDatainjectionClientInjection::showInjectionForm()
{"user":"7@GLPI_User","mem_usage":"0.030", 4.42Mio)"}
[2022-09-14 13:24:24] glpisqllog.ERROR: DBmysql::query() in /var/www/html/glpi/src/DBmysql.php line 370
*** MySQL query error:
SQL: INSERT INTO glpi_groups_users (users_id, groups_id) VALUES (NULL, '141')
Error: Column 'users_id' cannot be null
Backtrace :
src/DBmysql.php:1312
src/CommonDBTM.php:705 DBmysql->insert()
src/CommonDBTM.php:1304 CommonDBTM->addToDB()
...injection/inc/commoninjectionlib.class.php:1551 CommonDBTM->add()
...injection/inc/commoninjectionlib.class.php:1496 PluginDatainjectionCommonInjectionLib->effectiveAddOrUpdate()
...s/datainjection/inc/groupinjection.class.php:84 PluginDatainjectionCommonInjectionLib->processAddOrUpdate()
plugins/datainjection/inc/engine.class.php:147 PluginDatainjectionGroupInjection->addOrUpdateObject()
...datainjection/inc/clientinjection.class.php:267 PluginDatainjectionEngine->injectLine()
...datainjection/inc/clientinjection.class.php:219 PluginDatainjectionClientInjection::processInjection()
...datainjection/front/clientinjection.form.php:42 PluginDatainjectionClientInjection::showInjectionForm()
{"user":"7@GLPI_User","mem_usage":"0.017", 4.43Mio)"}

@cedric-anne
Copy link
Contributor

Please open a new issue.

@Hantiel
Copy link

Hantiel commented Sep 14, 2022

I just check this with Mapping - User and for User is working but after return to manager - same issue.

@kabassanov
Copy link

I just check this with Mapping - User and for User is working but after return to manager - same issue.

That is what I use, so I didn't check manager import...

@Hantiel
Copy link

Hantiel commented Sep 14, 2022

I just check this with Mapping - User and for User is working but after return to manager - same issue.

That is what I use, so I didn't check manager import...

Oh. Okey my mistake. Ok thanks I will try do something with that.
Thanks for help

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.

5 participants