Skip to content

Conversation

@Lainow
Copy link
Contributor

@Lainow Lainow commented Nov 19, 2024

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 !35251
  • Here is a brief description of what this PR does
    Fixed an error when inserting data linked to a relationship table (for example, the supplier identifier was removed from the list because the type was relationship).

Screenshots (if appropriate):

@Lainow Lainow force-pushed the fix-commondbrelation-injection branch from b8d0174 to 9c5735f Compare November 19, 2024 14:13
@Lainow Lainow requested review from Rom1-B and stonebuzz and removed request for stonebuzz November 19, 2024 14:49
Copy link
Contributor

@Rom1-B Rom1-B left a comment

Choose a reason for hiding this comment

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

It looks OK, can you get the customer to validate it?

// Ex : User -> groups_id -> Group_User
// groups_id should not be injected in User (field contains group name (string))
if ($option !== false && isset($option['displaytype']) && $option['displaytype'] == 'relation') {
if ($option !== false && isset($option['displaytype']) && $option['displaytype'] == 'relation' && !($item instanceof CommonDBRelation)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about the fix, with this example (inject groups_id from User object)

User -> groups_id (from Group_User)

The condition will return false (to delegate to specific case) -> OK

But with this

User -> name

The condition will return false -> KO

Because User is not an instance of CommonDBRelation

Suggested change
if ($option !== false && isset($option['displaytype']) && $option['displaytype'] == 'relation' && !($item instanceof CommonDBRelation)) {
if (($option !== false && isset($option['displaytype']) && $option['displaytype'] == 'relation') || !($item instanceof CommonDBRelation)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the || operator, the plugin doesn't insert any data, whereas with &&, all data is actually inserted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And I tested with a user like you said but everything works perfectly.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@stonebuzz
Copy link
Contributor

It looks OK, can you get the customer to validate it?

@stonebuzz
Copy link
Contributor

Reminder (adapt CHANGELOG.md)

@Lainow Lainow force-pushed the fix-commondbrelation-injection branch from 9153c87 to 8acb323 Compare December 11, 2024 13:47
@stonebuzz stonebuzz self-requested a review December 11, 2024 13:49
Co-authored-by: Stanislas <skita@teclib.com>
@stonebuzz
Copy link
Contributor

can you rebase (customer is OK with this change?)

@Lainow
Copy link
Contributor Author

Lainow commented Dec 12, 2024

can you rebase (customer is OK with this change?)

I'm waiting for their reply

@Lainow
Copy link
Contributor Author

Lainow commented Dec 17, 2024

That's good

@Rom1-B Rom1-B requested review from Rom1-B and stonebuzz December 17, 2024 11:18
@stonebuzz stonebuzz merged commit 351321d into pluginsGLPI:main Dec 17, 2024
3 checks passed
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