Fixing Error PHP at login in Nextcloud server logs
This error is related to a major change in php 8.4 and impacts the file external module of nc
PHP Error
Icewind\SMB\Native\NativeState::lseek(): Implicitly marking parameter $path as nullable is deprecated, the explicit nullable type must be used instead at /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php#346
install composer:
(Composer)
cd
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
php composer-setup.php
php -r "unlink('composer-setup.php');"
echo "${PATH//:/$'\n'}"
mv composer.phar /usr/bin/composer
Install php rector:
(https://github.com/rectorphp/rector)
# cd
# dnf install unzip
# exit
Install rector in home directory of user1, not as root:
(How do I install untrusted packages safely? Is it safe to run Composer as superuser or root? - Composer)
$ composer require --dev rector/rector
$ sudo -s
# cd /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb
Copy this minimal configuration in rector.php:
# vi rector.php
<?php
return Rector\Config\RectorConfig::configure()
->withPaths([__DIR__ . '/src'])
->withPhpVersion(Rector\ValueObject\PhpVersion::PHP_84)
->withRules([
Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector::class,
]);
Run rector:
# /home/user1/vendor/bin/rector
65/65 [ββββββββββββββββββββββββββββ] 100%
2 files with changes
====================
1) src/Exception/RevisionMismatchException.php:9
---------- begin diff ----------
@@ @@
use Throwable;
class RevisionMismatchException extends Exception {
- public function __construct(string $message = 'Protocol version mismatch', int $code = 0, Throwable $previous = null) {
+ public function __construct(string $message = 'Protocol version mismatch', int $code = 0, ?Throwable $previous = null) {
parent::__construct($message, $code, $previous);
}
}
----------- end diff -----------
Applied rules:
* ExplicitNullableParamTypeRector
2) src/Native/NativeState.php:343
---------- begin diff ----------
@@ @@
*
* @return false|int new file offset as measured from the start of the file on success.
*/
- public function lseek($file, int $offset, int $whence = SEEK_SET, string $path = null) {
+ public function lseek($file, int $offset, int $whence = SEEK_SET, ?string $path = null) {
if (!$this->state) {
throw new ConnectionException("Not connected");
}
----------- end diff -----------
Applied rules:
* ExplicitNullableParamTypeRector
next one 08/16/2025
SearchDAV\Query\Scope::__construct(): Implicitly marking parameter $path as nullable is deprecated, the explicit nullable type must be used instead at /var/www/nextcloud/3rdparty/icewind/searchdav/src/Query/Scope.php#54
# cd /var/www/nextcloud/3rdparty/icewind/searchdav
cp /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/rector.php rector.php
# /home/user1/vendor/bin/rector
Itβs fixed
These steps must be repeated after each NC update, as long as the moduleβs php syntax has not been corrected by dev.
I created a thread and got expert answers regarding compatibility issues with PHP 8.4. Requests were made on GitHub, and ernolf added a βpatchβ script to his collection.
Thanks to him.
(PHP 8.4 implicit nullable parameter deprecation in NC31 3rdparty module icewind)