- Issue created by @mglaman
- πΊπΈUnited States mglaman WI, USA
The comment here in
\Drupal\sqlite\Driver\Database\sqlite\Install\Tasks::connect
makes no sense:// We cannot use \Drupal::service('file_system')->getTempDirectory() // here because we haven't yet successfully connected to the database. $connection_info['default']['database'] = \Drupal::service('file_system')->tempnam(sys_get_temp_dir(), 'sqlite');
\Drupal\Core\File\FileSystem::getTempDirectory
does not use the database. It reads from settings and other static methods.However,
\Drupal\Core\File\FileSystem::tempnam
uses stream wrappers which requires a full container. - πΊπΈUnited States mglaman WI, USA
Okay, given this code:
$connection_info['default']['database'] = \Drupal::service('file_system')->tempnam(sys_get_temp_dir(), 'sqlite');
The result of
sys_get_temp_dir()
will not use a stream wrapper.\Drupal\Core\File\FileSystem::tempnam
is mostly for handling a tempnam the starts with a stream wrapper scheme. We'll never have that. We should just usetempnam
directly. - Merge request !8913SQLite install tasks requires the file_system service β (Open) created by mglaman
- Status changed to Needs review
about 2 months ago 3:11pm 24 July 2024 - Status changed to Needs work
about 2 months ago 3:40pm 24 July 2024 - πΊπΈUnited States mglaman WI, USA
This won't work because the connection class uses file_system in createDatabase: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/sqlit...
public function createDatabase($database) { // Verify the database is writable. $db_directory = new \SplFileInfo(dirname($database)); if (!$db_directory->isDir() && !\Drupal::service('file_system')->mkdir($db_directory->getPathName(), 0755, TRUE)) { throw new DatabaseNotFoundException('Unable to create database directory ' . $db_directory->getPathName()); } }
- π«π·France andypost
I think that's related to π Use \Drupal\Core\File\FileSystemInterface::getTempDirectory() instead of sys_get_temp_dir() where possible Needs work
- πΊπΈUnited States mglaman WI, USA
It's related, and adds more reliable on the file_system (which I think is not avoidable.)
- π«π·France andypost
That fix also has own issue) β¨ Make the public file system an optional configuration Active
- πΊπΈUnited States moshe weitzman Boston, MA
I've come across this too when testing the Drush site:install command on sqlite.