I understand PHP 8.1 RC3 is not officially supported yet but decided to report this anyway. It worked fine with 4.4.1 until I upgraded to 4.5. Unfortunately downgrade doesn't work (database has already been upgraded) so I did some debugging to figure out a workaround.
I tripple checked that Matomo 4.5 was properly installed with a diff -qr between the zip and my installation.
PHP Fatal error: During inheritance of IteratorAggregate: Uncaught Error: Class "Piwik\Session\SessionNamespace" not found in /var/www/.../core/Notification/Manager.php:203 Stack trace:#0 /var/www/.../core/Notification/Manager.php(147): Piwik\Notification\Manager::getSession()
Comment out: Manager::notify(Common::getRandomString(), $notification);
Indeed PHP 8.1 is not yet supported, but thanks for reporting the issue, that way we can get it working until it releases.
We are tracking all issues in https://github.com/matomo-org/matomo/issues/17686, but it seems like this hasn't been seen yet (maybe because I tested with Matomo 4.4.1)
Weirdly enough Matomo 4.5.0 is working fine for me in PHP 8.1.0beta2. I'll compile the latest release candidate and check again.
This seems like it might be a PHP issue... IteratorAggregate is an interface, nothing should inherit from it (just implement it). It also seems like this error might be covering up some other error. It might help to just print, log or file_put_contents the notification message in WebNotificationHandler to see what Matomo is trying to display.
Was thinking if maybe https://github.com/matomo-org/matomo/pull/17989 regressed something there but doesn't seem to reference
IteratorAggregate. Possible that PHP8.1 issue has always been there but not noticed if there was no notification triggered.
Possibly what happened in Matomo 4.5 is what @diosmosis suggested there's now a notice or warning or something that wasn't triggered before. Like eg if using IE11 or something and this now triggers the PHP 8.1 error but the error itself has been there in Matomo 4.4.
We might be able to reproduce it by triggering a warning there ourselves using PHP 8.1