Problem/Motivation
When running the security review on my relatively new (started at Drupal 9.4.7) site, it fails, with this from the watchdog log:
Error: Class "Symfony\Component\Filesystem\Filesystem" not found in Drupal\security_review\Checks\PrivateFiles->run() (line 38 of /modules/contrib/security_review/src/Checks/PrivateFiles.php)
Steps to reproduce
Proposed resolution
Require the symfony/filesystem component when requiring the module with Composer, if that is the correct required component for the PrivateFiles.php check.
If the check should be using the Drupal core version, not the Symfony version that is stated, then I would think that last use line of PrivateFiles.php needs updating to:
use Drupal\Core\Component\Filesystem\Filesystem;
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork security_review-3337726
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
smustgrave commentedCan you check your file permissions on vendor folder? Symfony\Component\Filesystem has been around from what I can tell in Drupal core for some time.
Comment #3
nattsIt wasn't a permissions issue on the root vendor directory.
A version of the Filesystem class is indeed in core, but the PrivateFiles.php check in this module wants to use the Symfony version:
So as a workaround, I had to require the component in Composer ('composer require symfony/filesystem') to get that specific version of the class into my codebase.
If the check should be using the Drupal core version, not the Symfony version that is stated, then I would think that last use line of PrivateFiles.php needs updating to:
use Drupal\Core\Component\Filesystem\Filesystem;Comment #4
nattsComment #6
smustgrave commentedThis work for you?
Comment #7
nattsI wasn't the author of the Private Files check, so I don't know which is the correct version of the Filesystem class to be used by it.
Comment #9
smustgrave commentedThis should ensure symfony is installed.
Comment #11
richardmetzger commentedJust installed this module and ran across the reported error.
composer require symfony/filesystem
solved it for me.