Skip to content

Conversation

@Mary-Clb
Copy link
Contributor

Checklist before requesting a review

  • 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.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.

Description

  • It fixes Problemas na importalçao de usuario GLPI 11/ User import issues in GLPI 11 #539 & !40013
  • When trying to inject data into the glpi_users table, fields with empty values that are defined as NOT NULL in the database do not take their assigned default values.
    The fix simply fills the isNullable() function in the corresponding class with the fields that can be null, allowing the plugin to distinguish NOT NULL fields and ensure they comply with their database constraints.

As discussed before with @Lainow:

@stonebuzz @Rom1-B would it be better to fix that in all classes in the PR ? I need a fix for the client but the problem will probably happen again with another class.

public function isNullable($field)
{
return true; // By default, all fields can be null
return in_array($field, [
Copy link
Contributor

Choose a reason for hiding this comment

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

For the user, that's a long list. Wouldn't it be easier to manage an exclusion list?

In any case, it needs to be sorted alphabetically, which will make it easier to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Your example only has 15 columns, so you can easily display everything on one screen without scrolling, which is not the case here.

For consistency, you can reorder the other case as well.

@Lainow Lainow self-requested a review November 3, 2025 09:27
public function isNullable($field)
{
return true; // By default, all fields can be null
return in_array($field, [
Copy link
Contributor

Choose a reason for hiding this comment

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

After running a few tests, only these fields need to be added to the list. The others do not return any errors, so I don't think it's necessary to add them.

public function isNullable($field)
    {
        return in_array($field, [
            'begin_date',
            'date_sync',
            'end_date',
            'last_login',
            'substitution_end_date',
            'substitution_start_date',
        ]);
    }

@Mary-Clb Mary-Clb force-pushed the fix/injection-nullable-fields branch from 6efb00c to 6ab35aa Compare November 3, 2025 09:45
@Lainow Lainow self-requested a review November 3, 2025 09:53
@Mary-Clb Mary-Clb requested a review from Rom1-B November 3, 2025 12:43
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.

Problemas na importalçao de usuario GLPI 11/ User import issues in GLPI 11

4 participants