Bonjour.
J’ai une interaction qui demande d’allumer les lampes d’appoint.
Jusqu’à présent, cette commande vocale appelait un virtuel dont l’action ‹ on › déclenchait un scénario allumant un équipement « une lampe d’appoint » et un autre « deux lampes d’appoint ».
J’ai demandé à Claude de m’aider à trouver pourquoi ça ne fonctionnait plus.
L’explication est dans la classe cmd.class.php: function pre_postExecCmd, un tag de type tableau passé à une commande avec une action avant exécution plante sous PHP 8
Solution proposée par Claude:
foreach ($_values as $key => $value) {
if (is_array($value) || is_object($value)) {
continue;
}
foreach ($options as &$option) {
if (!is_array($option)) {
$option = str_replace('#' . $key . '#', $value, $option);
}
}
unset($option);
}
Problème réglé, ma domotique est de nouveau 100% fonctionnelle
Maintenant, l’IA me dit que ça n’entraînera pas de problèmes pour les autres cas de figure, mais là, je laisse aux devs le soin d’y regarder.
noodom
Octobre 30, 2026, 4:58
2
Salut,
ca ressemble étrangement a ce post :
J’ai choisi d’ouvrir une issue plutôt qu’une PR vu qu’il y a plusieurs points de reflexions:
Merci Mips pour ton retour.
Sinon, dans ton post, tu peux formater le code que tu remontes pour que ça reste lisible.
Bonsoir,
un sujet identique a été ouvert :
Hello,
Je ne sais pas si ce sujet a déjà été abordé (je n’ai pas trouvé), mais depuis le passage a Debian 12 de mon Jeedom 4.6.2 (alors j’ai passé mon Jeedom 4.6.1 de Debian 11 vers 12) et juste après, j’ai maj en 4.6.2 donc je ne sais pas si c’est 4.6.2 ou Debian 12 le problème, mais en gros, mes scénario avec ASK ne fonctionne plus correctement.
Le wait n’est pas prit en compte et le scénario se termine directe, la notification envoyé via jeedom connect arrivé bien sur mon mobile mais j’ai a…
Ainsi qu’une issue :
ouvert 11:27AM - 28 Oct 26 UTC
bug
### Description
🔗 Community topic
https://community.jeedom.com/t/fonctionnem… ent-de-ask-depuis-le-passage-en-debian-12/151531/39?u=phpvarious
🐛 Bug Description
A fatal TypeError occurs during the execution of the str_replace() function within core/class/cmd.class.php when a post-execution command (pre_postExecCmd) is triggered by an ask command.
Since PHP 8.x (introduced with the migration to Debian 12), strict type errors in native functions throw a TypeError (which inherits from Throwable) rather than a standard Exception. Because of this, the current catch (Exception $e) block fails to intercept this error, leading to an unhandled Fatal Error that crashes the process instead of being gracefully logged.
🔍 Root Cause Analysis
During an ask command with a PostExecCmd, the $_values array contains an array for the answer key (e.g., "answer": ["Oui","Non"]).
Inside the nested loops, Jeedom correctly checks if $option is not an array:
```
if (!is_array($option)) {
$option = str_replace('#' . $key . '#', $value, $option);
}
```
However, it fails to check if $value is an array. When $key matches 'answer', $value is ["Oui","Non"]. This forces PHP to execute:
```
str_replace('#answer#', ["Oui","Non"], $option);
```
🛠️ Suggested Fix & Optimizations
1. Fix the TypeError array condition: Update the check to ensure $value is not an array before calling str_replace():
```
if (!is_array($option) && !is_array($value)) {
$option = str_replace('#' . $key . '#', $value, $option);
}
```
2. Fix the Try/Catch block: Replace Exception with \Throwable to properly intercept PHP 8.x TypeError instances:
```
} catch (\Throwable $e) {
log::add('cmd', 'error', __('Erreur lors de l\'exécution de', __FILE__) . ' ' . $action['cmd'] . ': ' . $message . '. ' . $this->getHumanName() . __('Détails :', __FILE__) . ' ' . log::exception($e));
}
```
3. Performance Optimization: Add an early check after initializing $options to skip disabled actions and avoid unnecessary iterations.
```
if (isset($options['enable']) && $options['enable'] == 0) continue;
```
📋 Stack Trace / Error Logs & Environment
• `Error: TypeError: str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string in /var/www/html/core/class/cmd.class.php`
• Jeedom Version: Core v4.6.1 (master)
• PHP Version: 8.2.35
• OS Version: Debian 12
### Type de matériel / Hardware type
Raspberry Pi
### Version de Jeedom / Jeedom Version
4.6.1
### Navigateur / Browser
Chrome Version 156.0.8078.48 (Build officiel) (64 bits)
### Étapes pour reproduire / Steps to reproduce
1. Create actionPreExecCmd or actionPostExecCmd on a command action/message.
2. Send an "ask" on this command with multiple possible responses into an scenario.
3. check the log.
### Logs
_No response_
Avec ce cas de figure ( interaction ), l’erreur peut potentiellement toucher un plus grand nombres d’utilisateurs.
Ah ben oui, je n’avais pas vu ce post, mais je n’utilise pas ask non plus…
Je reviens ici pour signaler que la solution de Claude IA ne convient pas pour tout. J’ai dû remettre la version de cmd.class pour pouvoir rétablir cette action:
et en appliquant cette modif ?
foreach ($this->getConfiguration($_type) as $action) {
try {
$options = array();
if (isset($action['options'])) {
$options = $action['options'];
}
if (is_array($_values) && count($_values) > 0) {
foreach ($_values as $key => $value) {
foreach ($options as &$option) {
if (!is_array($option)) {
$option = str_replace('#' . $key . '#', $value, $option);
}
}
}
$options['source'] = $this->getHumanName();
}
scenarioExpression::createAndExec('action', $action['cmd'], $options);
} catch (Exception $e) {
log::add('cmd', 'error', __('Erreur lors de l\'exécution de', __FILE__) . ' ' . $action['cmd'] . ': ' . $message . '. ' . $this->getHumanName() . __('Détails :', __FILE__) . ' ' . log::exception($e));
}
remplacer
if (!is_array($option)) {
par
if (!is_array($option) && !is_array($value)) {
SUPER! Thanx a lot! (ce sera pris en compte dans le prochain core?)