compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

MAE-887: Update testing workflow to PHP 8 container and fix failing tests #443

Closed omarabuhussein closed 1 year ago

omarabuhussein commented 1 year ago

Overview

As part of our plan to move to PHP 8.0, we are updating the unit-tests container to use the PHP 8 version of it. With this PHP update, we are also updating Drupal to version 7.79 and CiviCRM to version 5.51.3.

Doing that resulted in many failing tests, large part of them were fixed after applying this patch to our CiviCRM core: https://github.com/compucorp/civicrm-core/pull/91

The other issues are fixed in this commit: https://github.com/compucorp/uk.co.compucorp.membershipextras/pull/443/commits/04c625b11ee8de30f52fda352647662e9e6c96cf

which was caused by MembershipPaymentPlanProcessor/LineItemTest.php test trying to access non existent array elements (it used to throw a notice in PHP 7.4, but a warning in PHP8+, which what caused the tests to fail).

Other fixed issues

While looking around on my local PHP 8 site, I found that the membership creation form does not load, and the following error is thrown:

php_2      | Sep 27 09:37:18 php ccphp83_localhost:3977-drupal: 1664267838|172.30.0.1|http://ccphp83.localhost:3977|php|http://ccphp83.localhost:3977/civicrm/contact/view/membership?reset=1&action=add&cid=4&context=membership&snippet=json|http://ccphp83.localhost:3977/civicrm/contact/view?reset=1&cid=4&selectedChild=member|1||TypeError: array_merge(): Argument #1 must be of type array, null given in array_merge() (line 41 of /var/www/default/htdocs/httpdocs/profiles/compuclient/modules/contrib/civicrm/ext/uk.co.compucorp.membershipextras/CRM/MembershipExtras/Hook/PageRun/MemberPageTabColourUpdate.php).

which seems to happen because both inActiveMembers and activeMembers template variables might equal NULL, but in PHP8 you can no longer do an array_merge on NULL values and a fatal error is throw as the one we see above, I fixed it by making the default value for these variables set to empty array [] if their values are NULL.