Skip to content

Fix PHP 8+ TypeError in cmd::formatValue() when round() receives non-…#3124

Merged
Sekiro-kost merged 1 commit intojeedom:alphafrom
kwizer15:fix/cmd-format-value
Sep 25, 2025
Merged

Fix PHP 8+ TypeError in cmd::formatValue() when round() receives non-…#3124
Sekiro-kost merged 1 commit intojeedom:alphafrom
kwizer15:fix/cmd-format-value

Conversation

@kwizer15
Copy link
Contributor

@kwizer15 kwizer15 commented Sep 21, 2025

Description

Discussion community : https://community.jeedom.com/t/correctif-commit-442d472-masquage-dun-vrai-bug-de-typage-au-lieu-de-le-corriger-proprement/143439

Corrige une erreur fatale TypeError qui survient en PHP 8+ lorsque la fonction round() reçoit une valeur non-numérique dans cmd::formatValue().

Problème :

  • Quand calculValueOffset contient une formule qui retourne du texte (ex: #value# * 2 ~ 'mm'"2.4 mm"), l'appel à round() provoque une TypeError en PHP 8+
  • PHP 7.4 était plus permissif et acceptait les conversions implicites, PHP 8+ est strict sur le typage

Solution :

  • Vérification de is_numeric($_value) avant l'appel à round()
  • Log d'erreur pour informer l'utilisateur de sa mauvaise configuration
  • Conversion forcée avec floatval() pour maintenir la compatibilité
  • Correction appliquée uniquement quand historizeRound est configuré (ciblage précis du problème)

Suggested changelog entry

Correction d'une erreur fatale PHP 8+ dans cmd::formatValue() quand calculValueOffset retourne une valeur non-numérique

Related issues/external references

Fixes https://community.jeedom.com/t/php-fatal-error-uncaught-typeerror-in-cmd-class-php-on-line-1036-dans-le-log-http-error/143400

Types of changes

  • Bug fix (non-breaking change which fixes)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

@Sekiro-kost Sekiro-kost merged commit ed0c9a0 into jeedom:alpha Sep 25, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants