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

N°5139 - Let data that is null also be null at the other side-fix #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

odain-cbd
Copy link
Contributor

@odain-cbd odain-cbd commented May 15, 2024

Current PR intends to enhance "Reset or untouch" option (nullified configuration) to work also for empty string ("") fields values.

During data collection, fields can have a null value. during iTop object synchronization you can decide either

  • to reset the object field value on iTop side (during synchronization) and do nothing special in iTop configuration.
  • to update the field to a default value configured on collector side. use "default" configuration section for that purpose
  • to keep its previous value by leaving it untouch and sending '' to iTop synchonization. you have to configure collector with a nullified section.

we propose to have same "untouch" behaviour for empty string values collected. as a matter of fact null cannot be collected for some type of collectors (like CSV). which make the "nullify" feature unusable... seems like a bug to me.

  • cf documentation :

https://wiki.combodo.com/doku.php?id=extensions:itop-data-collector-base#reset_or_untouch

  • cf PR that brought the feature:

#7

@odain-cbd odain-cbd added the bug Something isn't working label May 15, 2024
@odain-cbd odain-cbd self-assigned this May 15, 2024
@odain-cbd odain-cbd requested a review from v-dumas May 15, 2024 13:46
@Hipska
Copy link
Collaborator

Hipska commented May 17, 2024

I'm only concerned on how to sync a NULL value into a nullable DECIMAL field in iTop. I think that is still not possible, even with these additions?

Edit: This is the correct link to the documentation: https://www.itophub.io/wiki/page?id=extensions:itop-data-collector-base#reset_or_untouch

@@ -594,7 +594,7 @@ protected function AddRow($aRow)
{
$aData = array();
foreach ($this->aCSVHeaders as $sHeader) {
if (is_null($aRow[$sHeader]) && $this->AttributeIsNullified($sHeader)) {
if (strlen($aRow[$sHeader])==0 && $this->AttributeIsNullified($sHeader)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (strlen($aRow[$sHeader])==0 && $this->AttributeIsNullified($sHeader)) {
if (strlen($aRow[$sHeader] ?? '') === 0 && $this->AttributeIsNullified($sHeader)) {

Otherwise in case a null value (as it seem it can be possible) it will trigger a warning with PHP 8.

@Molkobain
Copy link
Contributor

I'm only concerned on how to sync a NULL value into a nullable DECIMAL field in iTop. I think that is still not possible, even with these additions?

Edit: This is the correct link to the documentation: https://www.itophub.io/wiki/page?id=extensions:itop-data-collector-base#reset_or_untouch

Could we add a unit test on that to check and to ensure that we keep the intended behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants