SQLite filename will depend on schema definition strings#75
SQLite filename will depend on schema definition strings#75davidstrauss merged 2 commits intolcache:masterfrom
Conversation
davidstrauss
left a comment
There was a problem hiding this comment.
Mostly looks good, but let's change the hash used.
src/SQLiteL1.php
Outdated
| protected static function getDatabaseHandle($pool) | ||
| { | ||
| $path = join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), 'lcache-' . $pool)); | ||
| $schemaId = md5(implode(';', self::schemaStatements())); |
There was a problem hiding this comment.
While we hardly need to worry about collision issues here, government projects freak out if you even call MD5 from your code. They then require you to submit a statement for each use any why it's not cryptographically vulnerable. So, I recommend a truncated SHA-512 or a hash that doesn't even pretend to be cryptographically sound.
There was a problem hiding this comment.
I will go with the sha512, even though it's an overkill.
Off-topic: Shouldn’t we sanitize the $pool value in any way?
There was a problem hiding this comment.
The pool should only be set based on local system configuration; I don't think it needs to be sanitized.
Overview
This pull request:
Summary
There is a new utility that holds all the SQL queries needed to create the schema.
Based on them a hash is generated and added to the file name, making it unique.