Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ext/hash/hash_xxhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ PHP_HASH_API void PHP_XXH64Init(PHP_XXH64_CTX *ctx, HashTable *args)
zval *seed = zend_hash_str_find_deref(args, "seed", sizeof("seed") - 1);
/* This might be a bit too restrictive, but thinking that a seed might be set
once and for all, it should be done a clean way. */
if (seed && IS_LONG == Z_TYPE_P(seed)) {
XXH64_reset(&ctx->s, (XXH64_hash_t)Z_LVAL_P(seed));
return;
} else {
php_error_docref(NULL, E_DEPRECATED, "Passing a seed of a type other than int is deprecated because it is the same as setting the seed to 0");
if (seed) {
if (IS_LONG == Z_TYPE_P(seed)) {
XXH64_reset(&ctx->s, (XXH64_hash_t)Z_LVAL_P(seed));
return;
} else {
php_error_docref(NULL, E_DEPRECATED, "Passing a seed of a type other than int is deprecated because it is the same as setting the seed to 0");
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions ext/hash/tests/xxhash_options_without_seed.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Hash: xxHash options without a seed do not emit a deprecation
--FILE--
<?php

foreach (["xxh32", "xxh64", "xxh3", "xxh128"] as $a) {
var_dump(hash($a, "x", options: []) === hash($a, "x"));
}

?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
Loading