Skip to content

Regression: password_hash() global const algo null when optional $options passed (ext/standard/password.c) #10453

Description

@PurHur

Category

stdlib + compile lowering · php-src-strict

Problem

password_hash($password, PASSWORD_BCRYPT) works, and password_hash($password, 1, ['cost' => 4]) works, but password_hash($password, PASSWORD_BCRYPT, ['cost' => 4]) passes null as argument #2 ($algo) → TypeError. Zend accepts the call and returns a bcrypt hash string.

Related but distinct from #9275 (PASSWORD_DEFAULT resolves null in other contexts).

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_password_hash_options.php 2>&1'
# no-opt ok
# with-opt TypeError: Argument #2 ($algo) must be of type string|int, null given
# lit-opt ok

test/repro/maintainer_gap_password_hash_options.php:

password_hash('test', PASSWORD_BCRYPT);              // ok
password_hash('test', PASSWORD_BCRYPT, ['cost' => 4]); // TypeError — must hash
password_hash('test', 1, ['cost' => 4]);             // ok

php-src reference

  • ext/standard/password.cPHP_FUNCTION(password_hash)

Implementation (PHP-in-PHP)

Done when

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions