This problem is definitely caused by opcache. I spent all 8 hours since my last reply to reliably reproduce this issue, understand why it is happening and address it.
Akeeba Backup ships with a file administrator/components/com_akeeba/Container.php which contains a custom component Container class. This extends from the base container class of the backend FOF framework used in all of our software.
Akeeba Backup 4, 5, 6 and 7 were using FOF 3. Akeeba Backup 8 uses FOF 4. Therefore the Container.php file extends from a differently namespaced class.
After Joomla has finished installing the component (but not the entire package) it runs the post-installation script of the component. The post-installation script needs to load the component's container to check if there are old backup profiles that need to be migrated to new settings, if your component settings regarding the front-end backup / JSON API need to be migrated from the old, unified to option to per-feature options and to check whether it should send anonymous information about the Joomla, PHP and MySQL versions used on your server.
It does that by calling the FOF framework code to get a container. FOF will check if there is a custom container class and use it instead.
If opcache is disabled this is not a problem. FOF 4 has been installed. The new Container.php extends from FOF 4's container. Both are in the same framework family and there is no error.
When opcache is enabled it's possible that PHP had already seen the old Container.php and kept its compiled opcode in the PHP opcode cache. This could happen if your server is configured to not revalidate (check for changed timestamps on) .php files, or if the revalidation frequency is set to something longer than it took between the server last seeing the Container.php and the post-installation script running. This is why we never saw that during our testing. Our servers are configured to do revalidation every 5 to 10 seconds. The only way I was able to reproduce this was to set the revalidation frequency to 60 seconds, go to Joomla's Control Panel, wait for Joomla to show there are updates available and then immediately go to the Update page and install the update.
Why is waiting on the Control Panel page critical? Because looking for updates Joomla will load the installer plugins. If at least one of the installer plugins for Akeeba Backup, Admin Tools or Akeeba Ticket System is enabled this will end up trying to get the container for Akeeba Backup using its then-current framework version which, before the update, is FOF 3. The framework code will load the Container.php file in Akeeba backup's directory and opcache will cache it.
From that point on, the clock is ticking.
You need to go to Extensions, Manage, Update, select Akeeba Backup and click on Update. Joomla will download the ZIP file, extract it, and start installing the contained extensions. The first extension it installs is the Akeeba Backup component. After it's done copying files around it will run the post-restoration script. Mark the time.
If the time elapsed is less than the opcache revalidation frequency OR if opcache is set to never revalidate files the attempt to load the component's container will fail because the custom container is FOF 3 but the framework is FOF 4. This disparity causes the error message
Argument 1 passed to FOF40\Platform\Joomla\Platform::__construct() must be an instance of FOF40\Container\Container, instance of Akeeba\Backup\Admin\Container given, called in /var/www/vhosts/master.my-landingpages.de/j3_master/libraries/fof30/Container/Container.php on line 217
The tricky part is that error message references Akeeba\Backup\Admin\Container which is the namespaced class contained in the Container.php file. Frustratingly, the file said this class extends the FOF 4 container but the error message said that it doesn't. Why? Because opcache was NOT loading the file, it was serving the precompiled file from before the update started which was, indeed, extending the FOF 3 container.
We were trying to invalidate the opcode cache using opcache_reset(). The PHP documentation says that it invalidates the opcode cache. Reading that any sane person understand "resets the opcode cache when called" especially since it returns a boolean which, per the documentation, is true when the opcache has been invalidated.
In actual fact it DOES NOT reset the opcache when called! It WILL reset the opcache AFTER PHP finishes processing the request. You'd think that this massively important point would be documented and put into a big, fat warning box. But no. They never mention it. There is a downrated, greyed out, user comment in PHP's documentation page saying as much. Seeing it I thought "you don't suppose the PHP developer did something that stupid, do you?". So I decided to try a different approach.
Instead of using opcache_reset() I used opcache_invalidate(). The difference is that opcache_invalidate() takes a parameter, the path to a file, and only invalidates this particular file. I did that for the Container.php file. This solved the issue.
Seeing that this worked I wanted to know if I was on to something or not. I restored the site I was using as a test, the one where I was able to reliable reproduce the issue the previous 80-odd times already. Sure enough, installing 8.0.1 reproduced the issue. Restore the site again, install the version with opcache_invalidate(). The problem disappeared.
Then I disabled opcache completely. Restored the site again. 8.0.1 installed without a problem. Another restore. Install the modified version. Installed without a problem.
I repeated these tests in different order another 20 times. In every single case the only way that this could be reproduced was if and only if the opcache was enabled and I was NOT using opcache_invalidate().
So I am, definitely, 100% certain that the problem is with opcache. I have full understanding of the internal workings now.
Which brings us back to your claim that you disabled opcache and had the same issue. HOW did you disable opcache? You cannot disable it in php.ini, .user.ini or .htaccess because OPcache's configuration options are marked PHP_INI_ALL, i.e. they only apply in the main, server-wide php.ini file. After changing that file you need to restart PHP-FPM (if you're using it) and/or your web server. If you did anything different you have not, in fact, disabled opcache. You can verify this from the site's System, System Information page. opcache.enabled will show On instead of Off. I know not only because I read the PHP documentation but also because I did try using php.ini and .user.ini to make sure that they do not, in fact, allow the OPcache to be disabled.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!