Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • L Line Item Editor
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Extensions
  • Line Item Editor
  • Merge requests
  • !73

Fix error when adding new lineitem on PHP8

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open olayiwola_compucorp requested to merge olayiwola_compucorp/lineitemedit:MAE-988-fix-empty-amount into master Dec 16, 2022
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1

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

Before

The user is unable to add a new lineitem. lineitem2

After

The user is able to add a new lineitem. lineitem1

Technical Details

This issue is caused by an invalid Type operation at https://lab.civicrm.org/extensions/lineitemedit/-/blob/master/CRM/Lineitemedit/Util.php#L510

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.

Comment

PHP 8.0 and CiviCRM 5.51.3

Edited Dec 16, 2022 by olayiwola_compucorp
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: MAE-988-fix-empty-amount