streamingltd / MEDIAL-Moodle-Activity

The MEDIAL activity plugin for Moodle
GNU General Public License v3.0
3 stars 8 forks source link

PHPUnit Fatal error 3.9.4+ #9

Closed aspark21 closed 3 years ago

aspark21 commented 3 years ago

Fatal error: Cannot redeclare str_contains() (previously declared in /var/www/html/vendor/symfony/polyfill-php80/bootstrap.php:29) in /var/www/html/mod/helixmedia/locallib.php on line 760

aspark21 commented 3 years ago

https://github.com/streamingltd/MEDIAL-Moodle-Activity/blob/master/locallib.php#L760 https://github.com/symfony/polyfill-php80/blob/main/bootstrap.php#L29

aspark21 commented 3 years ago

This specifically happens with the 3.9.4+ weekly release 20210130 but not with the 3.9.4 official release

I think it's likely due to some of the Behat changes https://moodle.org/mod/forum/discuss.php?d=417286 https://tracker.moodle.org/browse/MDL-66979

str_contains is only available in PHP 8.0 onwards. So not sure what this plugin has been relying on for it but looks like it will need to adapt

aspark21 commented 3 years ago

https://php.watch/versions/8.0/str_contains

aspark21 commented 3 years ago

@tim1mw this one's a pretty urgent one for us at it completely breaks our ability to run PHPUnit and Behat for our builds before they go to prod

tim1mw commented 3 years ago

@aspark21 I'll see what I can do but Friday 5th is the earliest I can possibly look at this.

If you need a quick response, please use the MEDIAL support email, we don't use github for error reports so this isn't monitored. I should probably see if I can turn github Issues off to avoid confusion.

aspark21 commented 3 years ago

I have asked colleagues to log a ticket but this is useful to have a shared understanding as I wouldn't have access to log tickets & respond to them.

tim1mw commented 3 years ago

This method should have been prefixed helixmedia_ in the first place to avoid potential clashes, so I've taken the simple approach and renamed it. This is only used in locallib.php so only a few changes were needed. In order to make it easier to release fixes outside of the normal release cycle that might be of use to others, I've added a new branch to this git repo prerelease-fixes and committed the change there.

aspark21 commented 3 years ago

Just to confirm this resolves the unit test errors and we have deployed to prod, all working ok 😄

Thanks for the prompt resolution of this unexpected spanner

danowar2k commented 3 years ago

We've run into this problem not because we use PHP 8.0, but because we depend on symphony in our Moodle installation. When will this fix be released in a version?

tim1mw commented 3 years ago

It's available right now in the prerelease-fixes branch here if you need this immediately:

https://github.com/streamingltd/MEDIAL-Moodle-Activity/tree/prerelease-fixes