PHP 8.1 - Math operation got error "Unsupported operand types: string"

Created on 20 October 2022, almost 2 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

I'm not sure this should be created in Tamper or ECA or ECA tamper module. When update PHP from 7.4 to 8.1, I got an error "Unsupported operand types: string" when saving a content to trigger the math operation.

AH01071: Got error 'PHP message: TypeError: Unsupported operand types: string - string in /modules/contrib/tamper/src/Plugin/Tamper/Math.php on line 152 #0 /modules/contrib/eca_tamper/src/Plugin/Action/Tamper.php(51): Drupal\\tamper\\Plugin\\Tamper\\Math->tamper()\n#1 /modules/contrib/eca/src/Entity/Objects/EcaAction.php(100): Drupal\\eca_tamper\\Plugin\\Action\\Tamper->execute()\n#2 /modules/contrib/eca/src/Processor.php(188): Drupal\\eca\\Entity\\Objects\\EcaAction->execute()\n#3 /modules/contrib/eca/src/Processor.php(146): Drupal\\eca\\Processor->executeSuccessors()\n#4 /modules/contrib/eca/src/EventSubscriber/EcaBase.php(76): Drupal\\eca\\Processor->execute()\n#5 [internal function]: Drupal\\eca\\EventSubscriber\\EcaBase->on...', referer: https://batch?id=4872&op=start

Steps to reproduce

Upgrade to PHP 8.1. Leave one field that want to do the calculation to blank. Then, save the content to trigger the calculation. Error will appear. However, replace that blank field with number 0, the ECA will work as it should.

💬 Support request
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024