From 60338270e1dfbcd2939030715571cf89f8c12636 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Sun, 18 Oct 2026 17:24:46 +0200 Subject: [PATCH] ext/hash: don't emit xxh64 seed deprecation when no seed is given --- ext/hash/hash_xxhash.c | 12 +++++++----- ext/hash/tests/xxhash_options_without_seed.phpt | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 ext/hash/tests/xxhash_options_without_seed.phpt diff --git a/ext/hash/hash_xxhash.c b/ext/hash/hash_xxhash.c index b7253b0c99c0..a63149f2fc23 100644 --- a/ext/hash/hash_xxhash.c +++ b/ext/hash/hash_xxhash.c @@ -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"); + } } } diff --git a/ext/hash/tests/xxhash_options_without_seed.phpt b/ext/hash/tests/xxhash_options_without_seed.phpt new file mode 100644 index 000000000000..87660f1f57fc --- /dev/null +++ b/ext/hash/tests/xxhash_options_without_seed.phpt @@ -0,0 +1,15 @@ +--TEST-- +Hash: xxHash options without a seed do not emit a deprecation +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true)