Skip to content

Commit d68feb7

Browse files
LainowRom1-B
andauthored
Fix certificates expirations dates (#502)
* Fix certificates expirations dates * Update CHANGELOG * Fix indentation * Fix checktype * Fix infocom update * Fix php cs * Fix php cs * Fix php cs * Add isNullable is PluginDatainjectionInjectionInterface * Fix genericobject injection * Remove isNullable of InjectionInterface * Update inc/infocominjection.class.php --------- Co-authored-by: Romain B. <[email protected]>
1 parent 130a4de commit d68feb7

File tree

100 files changed

+510
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+510
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [Unreleased]
8+
## [unreleased] -
99

1010
### Fixed
11-
11+
- Fix injection to the `date_expiration` of certificates
1212
- Fix the `Task completed` message during plugin update
1313

1414
## [2.14.3] - 2025-09-16

inc/applianceinjection.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public function connectedTo()
5050
return [];
5151
}
5252

53+
public function isNullable($field)
54+
{
55+
return true; // By default, all fields can be null
56+
}
57+
5358
/**
5459
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()
5560
**/

inc/autoupdatesysteminjection.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function connectedTo()
5555
return [];
5656
}
5757

58+
public function isNullable($field)
59+
{
60+
return true; // By default, all fields can be null
61+
}
62+
5863

5964
public function getOptions($primary_type = '')
6065
{

inc/budgetinjection.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function connectedTo()
5656
return [];
5757
}
5858

59+
public function isNullable($field)
60+
{
61+
return true; // By default, all fields can be null
62+
}
63+
5964

6065
/**
6166
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()

inc/cartridgeiteminjection.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function connectedTo()
5555
return [];
5656
}
5757

58+
public function isNullable($field)
59+
{
60+
return true; // By default, all fields can be null
61+
}
62+
5863

5964
/**
6065
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()

inc/certificateinjection.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public function connectedTo()
5050
return [];
5151
}
5252

53+
public function isNullable($field)
54+
{
55+
return true; // By default, all fields can be null
56+
}
57+
5358
/**
5459
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()
5560
**/
@@ -70,6 +75,9 @@ public function getOptions($primary_type = '')
7075
"bool" => [9, 86]
7176
];
7277

78+
// Add date check type to Expiration date Search Option
79+
$tab[10]['checktype'] = 'date';
80+
7381
return PluginDatainjectionCommonInjectionLib::addToSearchOptions($tab, $options, $this);
7482
}
7583

inc/commoninjectionlib.class.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,10 +930,10 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb = false)
930930
if ($itemtype === User::class && $field === "pdffont" && $fromdb) {
931931
return;
932932
}
933+
$injectionClass = self::getInjectionClassInstance($itemtype);
933934
// TODO awfull hack, text ftom CSV set more than once, so check if "another" value
934935
if (isset($this->values[$itemtype][$field]) && $this->values[$itemtype][$field] != $value) {
935936
// Data set twice (probably CSV + Additional info)
936-
$injectionClass = self::getInjectionClassInstance($itemtype);
937937
$option = self::findSearchOption($injectionClass->getOptions($itemtype), $field);
938938

939939
if (isset($option['displaytype']) && $option['displaytype'] == 'multiline_text') {
@@ -955,7 +955,7 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb = false)
955955
}
956956
} else { // First value
957957
if (empty($value)) {
958-
if (isForeignKeyField($field) || (strpos($field, 'is_') !== false)) {
958+
if (isForeignKeyField($field) || (strpos($field, 'is_') !== false) || (method_exists($injectionClass, 'isNullable') && !$injectionClass->isNullable($field))) {
959959
// If the field is an id, we set it to 0
960960
$this->values[$itemtype][$field] = self::DROPDOWN_EMPTY_VALUE;
961961
} else {
@@ -1596,7 +1596,6 @@ public function processAddOrUpdate()
15961596

15971597
foreach ($this->values as $itemtype => $data) {
15981598
//Do not process primary_type
1599-
16001599
if ($itemtype != get_class($item)) {
16011600
$injectionClass = self::getInjectionClassInstance($itemtype);
16021601
$item = new $itemtype();

inc/computer_iteminjection.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public function connectedTo()
6464
return $CFG_GLPI["directconnect_types"];
6565
}
6666

67+
public function isNullable($field)
68+
{
69+
return true; // By default, all fields can be null
70+
}
71+
6772

6873
/**
6974
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()

inc/computerinjection.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function connectedTo()
5656
return [];
5757
}
5858

59+
public function isNullable($field)
60+
{
61+
return true; // By default, all fields can be null
62+
}
63+
5964

6065
/**
6166
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()

inc/computermodelinjection.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function connectedTo()
5555
return [];
5656
}
5757

58+
public function isNullable($field)
59+
{
60+
return true; // By default, all fields can be null
61+
}
62+
5863

5964
/**
6065
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()

0 commit comments

Comments
 (0)