documentation on fnv1a64 is lacking, but tests show it was only introduced with PHP 5.6

This commit is contained in:
El RIDO 2019-05-10 22:46:39 +02:00
parent 9b6b25dac0
commit 02f3cc739f
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
4 changed files with 4 additions and 4 deletions

View file

@ -108,7 +108,7 @@ abstract class AbstractModel
$this->_data = $data; $this->_data = $data;
// calculate a 64 bit checksum to avoid collisions // calculate a 64 bit checksum to avoid collisions
$this->setId(hash('fnv1a64', $data['ct'])); $this->setId(hash(version_compare(PHP_VERSION, '5.5') > 0 ? 'fnv1a64' : 'fnv164', $data['ct']));
} }
/** /**

View file

@ -98,7 +98,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'); $keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z');
$ids = array(); $ids = array();
foreach ($keys as $key) { foreach ($keys as $key) {
$ids[$key] = hash('fnv1a64', $key); $ids[$key] = hash('fnv164', $key);
$this->_model->delete($ids[$key]); $this->_model->delete($ids[$key]);
$this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist"); $this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
if (in_array($key, array('y', 'z'))) { if (in_array($key, array('y', 'z'))) {

View file

@ -88,7 +88,7 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'); $keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z');
$ids = array(); $ids = array();
foreach ($keys as $key) { foreach ($keys as $key) {
$ids[$key] = hash('fnv1a64', $key); $ids[$key] = hash('fnv164', $key);
$this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist"); $this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
if (in_array($key, array('x', 'y', 'z'))) { if (in_array($key, array('x', 'y', 'z'))) {
$this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste"); $this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste");

View file

@ -284,7 +284,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z'); $keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
$ids = array(); $ids = array();
foreach ($keys as $key) { foreach ($keys as $key) {
$ids[$key] = hash('fnv1a64', $key); $ids[$key] = hash('fnv164', $key);
$store->delete($ids[$key]); $store->delete($ids[$key]);
$this->assertFalse($store->exists($ids[$key]), "paste $key does not yet exist"); $this->assertFalse($store->exists($ids[$key]), "paste $key does not yet exist");
if (in_array($key, array('x', 'y', 'z'))) { if (in_array($key, array('x', 'y', 'z'))) {