processmaker icon indicating copy to clipboard operation
processmaker copied to clipboard

Casting to array in FormalExpression (arrayget) - FOUR-7094

Open paulosakamoto opened this issue 3 years ago • 0 comments

Issue & Reproduction Steps

This bug was encountered during the PM4EH-184 task.

It was expected that the process would only move forward after receiving the callback call.

In the process that manages the Data Connector implementation, there is a gateway that checks for a callback. In the "Yes" path, there is a FormalExpression that fails, even though there is a callback in the parent process. This takes the process in the wrong flow, causing the bug.

I suspect it's not a regression issue and that this function has never worked, following the evidence below.

https://github.com/ProcessMaker/processmaker/commit/83993df2eebe2d62ea97bcec8210f5d9efce450c

https://github.com/ProcessMaker/processmaker/blob/develop/ProcessMaker/Models/FormalExpression.php#L281

https://github.com/ProcessMaker/processmaker/commit/367eb3e4bfd6d50a37759a6b0021f5e14fc672da#diff-9b17ccd32dc2f52a975a7da00cf04f6b84b46e5eabf7803efca50cf34e6d9bd1R80

https://github.com/laravel/framework/blob/6.x/src/Illuminate/Support/Arr.php#L284

https://github.com/laravel/framework/blob/7e82e1a272a72d75b4cd7f35a2267e9af5d642c2/src/Illuminate/Support/Arr.php#L21

Solution

Cast to array before calling Arr::get.

How to Test

Run the command:

php vendor/phpunit/phpunit/phpunit --colors --stop-on-failure tests/unit/ProcessMaker/Models/FormalExpressionTest.php --filter=testArrayGet

Another test can be done by following the "Steps to Reproduce" in this ticket FOUR-7094.

Related Tickets & Packages

Code Review Checklist

  • [ ] I have pulled this code locally and tested it on my instance, along with any associated packages.
  • [ ] This code adheres to ProcessMaker Coding Guidelines.
  • [ ] This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • [ ] This solution fixes the bug reported in the original ticket.
  • [ ] This solution does not alter the expected output of a component in a way that would break existing Processes.
  • [ ] This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • [ ] This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • [ ] This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • [ ] This ticket conforms to the PRD associated with this part of ProcessMaker.

paulosakamoto avatar Nov 18 '22 12:11 paulosakamoto