Revision 0548a1f2
Gestion des valeurs vides dans les dépendances
Corrige la détection des valeurs vides dans les dépendances, qui
doivent être traitées comme si on avait passé null explicitement.
Change-Id: Ia2fc1c3779fb5564863baab64afd90ecb2e7e352
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2523
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Yves OUATTARA <yves.ouattara@c-s.fr>
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
src/plugins/vigilo/Vigilo/VigiloDepends.php | ||
---|---|---|
9 | 9 |
|
10 | 10 |
public function __construct($host = null, $service = null, $weight = 1, $warningWeight = null) |
11 | 11 |
{ |
12 |
if (null === $host && null === $service) { |
|
13 |
throw new Exception('Invalid dependency'); |
|
12 |
/* GLPI signale parfois l'absence de valeur via des chaînes vides, |
|
13 |
plutôt qu'en utilisant la constante null. */ |
|
14 |
if ('' === $host) { |
|
15 |
$host = null; |
|
16 |
} |
|
17 |
if ('' === $service) { |
|
18 |
$service = null; |
|
14 | 19 |
} |
15 | 20 |
|
16 |
if ('' === $host || '' === $service) {
|
|
21 |
if (null === $host && null === $service) {
|
|
17 | 22 |
throw new Exception('Invalid dependency'); |
18 | 23 |
} |
19 | 24 |
|
... | ... | |
22 | 27 |
throw new Exception('Invalid dependency'); |
23 | 28 |
} |
24 | 29 |
|
25 |
if (null !== $host && null !== $warningWeight) {
|
|
30 |
if (null === $service && null !== $warningWeight) {
|
|
26 | 31 |
// L'état "warning" n'existe pas pour les hôtes. |
27 | 32 |
throw new Exception('Invalid dependency'); |
28 | 33 |
} |
Also available in: Unified diff