Opencast-Moodle / moodle-block_opencast

Block to manage Opencast publications in moodle
21 stars 27 forks source link

Backward incompatibility of PHP versions #359

Closed taraghi closed 4 months ago

taraghi commented 4 months ago

Hi,

Running block_opencast on Moodle 4.1.9 with PHP 7.4 we encounter PHP errors caused by used php function which are available since PHP 8

For instance: I, as manager, switched my role to another user role in a course with block opencast added containing a series. Then I switched back my role to the manager, and got the following error message

Bildschirmfoto 2024-02-26 um 15 27 47

The php function str_contains() exist since PHP 8. As we have PHP 7.4 running, this leads to a PHP error. There are alternative php functions such as strpos() that can be used instead, in order to support lower PHP versions.

The php 8 function was introduced here: https://github.com/Opencast-Moodle/moodle-block_opencast/blob/8c00eec04409e0c09bd10182fbf1f2cba894555b/block_opencast.php#L217 via this commit: https://github.com/Opencast-Moodle/moodle-block_opencast/commit/8c00eec04409e0c09bd10182fbf1f2cba894555b

The following php 8 functions will also make problem: str_starts_with: https://github.com/Opencast-Moodle/moodle-block_opencast/blob/8c00eec04409e0c09bd10182fbf1f2cba894555b/block_opencast.php#L228

Thank you