Compatibility with s3fs

Created on 11 October 2024, about 1 month ago

Problem/Motivation

Enabling the module on a site with s3fs module enabled throws this error on all consequent page loads:

The website encountered an unexpected error. Try again later.
TypeError: Drupal\crowdsec\Client::__construct(): Argument #4 ($fileSystem) must be of type Drupal\Core\File\FileSystem, Drupal\s3fs\S3fsFileSystemD103 given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 in Drupal\crowdsec\Client->__construct() (line 88 of modules/contrib/crowdsec/src/Client.php).

Proposed resolution

My quick and dirty solution was to remove the $fileSystem argument from the constructor in Client.php and modify the cache function at the end of the file like this:

-        $this->cache = new PhpFiles(['fs_cache_path' => $this->fileSystem->getTempDirectory() . '/crowdsec'], $this->logger);
+        $this->cache = new PhpFiles(['fs_cache_path' => \Drupal::service('file_system')->getTempDirectory() . '/crowdsec'], $this->logger);

Remaining tasks

While the solution above seems to do the job, I will admit I have no idea whether it's clean or dirty. Happy to provide a patch if needed.

🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

🇭🇺Hungary dr. gubó

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024