twomice / com.joineryhq.percentagepricesetfield

Other
5 stars 10 forks source link

fix array key for PHP 8 compatibility #48

Closed MegaphoneJon closed 1 year ago

MegaphoneJon commented 2 years ago

This extension crashes on PHP 8.0 with:

Error: Unknown named parameter $_GET in percentagepricesetfield_civicrm_alterContent()

The reason is line 213 uses call_user_func_array. The PHP docs show a changelog for this function:

8.0.0 | args keys will now be interpreted as parameter names, instead of being silently ignored.

The function signature of the called function is:

function _percentagepricesetfield_get_content_pricesetid_function($content, $context, $tplName, $object, $_get) {

While all the other elements of $args use an indexed array, $args['_GET'] has a named array key, and it doesn't match the function signature (which uses $_get, not $_GET).

I'm also happy to submit a second PR to not access $_GET directly, and use CRM_Utils_Request, but I wanted to keep the scope of this PR limited to fixing the critical issue.

twomice commented 1 year ago

Merged, thanks @MegaphoneJon !