Handle lock with long key
This commit is contained in:
parent
154f7e9839
commit
f82682424e
|
@ -74,7 +74,7 @@ class FlockStore implements StoreInterface, BlockingStoreInterface
|
||||||
|
|
||||||
$fileName = sprintf('%s/sf.%s.%s.lock',
|
$fileName = sprintf('%s/sf.%s.%s.lock',
|
||||||
$this->lockPath,
|
$this->lockPath,
|
||||||
preg_replace('/[^a-z0-9\._-]+/i', '-', $key),
|
substr(preg_replace('/[^a-z0-9\._-]+/i', '-', $key), 0, 50),
|
||||||
strtr(substr(base64_encode(hash('sha256', $key, true)), 0, 7), '/', '_')
|
strtr(substr(base64_encode(hash('sha256', $key, true)), 0, 7), '/', '_')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -73,4 +73,25 @@ class FlockStoreTest extends AbstractStoreTest
|
||||||
|
|
||||||
$store->delete($key);
|
$store->delete($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSaveSanitizeLongName()
|
||||||
|
{
|
||||||
|
$store = $this->getStore();
|
||||||
|
|
||||||
|
$key = new Key(str_repeat(__CLASS__, 100));
|
||||||
|
|
||||||
|
$file = sprintf(
|
||||||
|
'%s/sf.Symfony-Component-Lock-Tests-Store-FlockStoreTestS.%s.lock',
|
||||||
|
sys_get_temp_dir(),
|
||||||
|
strtr(substr(base64_encode(hash('sha256', $key, true)), 0, 7), '/', '_')
|
||||||
|
);
|
||||||
|
// ensure the file does not exist before the store
|
||||||
|
@unlink($file);
|
||||||
|
|
||||||
|
$store->save($key);
|
||||||
|
|
||||||
|
$this->assertFileExists($file);
|
||||||
|
|
||||||
|
$store->delete($key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue