How I fixed Nextcloud PHP Fatal error: Class contains 1 abstract method and must therefore be declared abstract
Recently my Nextcloud 16 instance (running via PHP 7.2 FPM on Nginx) return HTTP status 500 (internal server error) when trying to access it.
Analyzin the webserver log revealed this error message:
FastCGI sent in stderr: "PHP message: PHP Fatal error: Class OC\Authentication\Token\PublicKeyToken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (OC\Authentication\Token\IToken::setExpires) in /var/sites/nextcloud.mydomain.com/lib/private/Authentication/Token/PublicKeyToken.php on line 47" while reading response header from upstream, client: 2003:ea:b747:ee00:7491:f492:480:57a9, server: nextcloud.mydomain.com, request: "PROPFIND /remote.php/dav/files/admin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "nextcloud.mydomain.com"
After some research, I found out that - at least in my case - the issue could be fixed by flushing the PHP opcache:
sudo service php7.2-fpm reload
After that, nextcloud started to work properly again.