The problematic code is:
unlink(getcwd() . '/index.php');
unlink(getcwd() . '/prestashop.zip');
rename(getcwd() . '/index.php.temp', getcwd() . '/index.php');
The first line deletes a file and the third line renames a file to that name. Under PHP 8 the third line gets an "access denied" error. When I look afterwards in the file system the file has been deleted and the third line hasn't been executed.
Does anyone have an explanation for what is happening here?