Skip to content

Fix error when adding new lineitem on PHP8

This PR fixes an error that occurs when adding a new lineitem to a contribution.


The user is unable to add a new lineitem. lineitem2


The user is able to add a new lineitem. lineitem1

Technical Details

This issue is caused by an invalid Type operation at

Assuming $updatedAmount = "40.0"

and CRM_Utils_Array::value('fee_amount', $updatedContribution, 0) = ""

It would try to do "40.0" - "", This would only throw a notice in PHP7.4 and treat the empty string as 0, but in PHP8.0+ this is not valid and would throw the error Error: Uncaught TypeError: Unsupported operand types: string - string.


PHP 8.0 and CiviCRM 5.51.3

Edited by olayiwola_compucorp

Merge request reports