Skip to content

[PHPUnit] Possible bugs surfaced from coverage improvements #76

Closed

Description

@tyrsson

Package Version

0.5.x

Php Version

8.4

Database Engine

MySQL

Basic Information

The following findings need to be verified. Found during #57

Findings to flag (not fixed — src bugs uncovered):

Statement::bindParametersFromContainer — plain-array params (no errata) build empty bind type string → mysqli_stmt::bind_param(): Argument #1 ($types) must not be empty. Worked around in tests via ParameterContainer + errata. Real bug in execute(array) path.
getTrigger()/getTriggers() throw TypeError: TriggerObject::setActionOrder() wants string, MySQL INFORMATION_SCHEMA.TRIGGERS.ACTION_ORDER returns int. Library bug.
Statement::prepare() InvalidQueryException branch dead under PHP 8.1+ (mysqli throws mysqli_sql_exception, never returns false).
Metadata\Source::loadConstraintDataNames()

Steps to Reproduce

Expected Behavior

No response

Actual behavior?

Unexpected test behavior.

Additional Info

No response

Activity

  1. added this to the 0.5.0 milestone on Aug 12, 2026
  2. added theissue type on Aug 12, 2026
  3. tyrsson commented on Sep 24, 2026

    @tyrsson
    MemberAuthor

    Reproduced outside the test suite, on the ordinary path in a Mezzio app, with no hand-built container and no explicit errata.

    Env: PHP 8.4.24, phpdb ^0.6.x-dev, phpdb-mysql ^0.5.x-dev, MySQL 9.7.

    $sql->prepareStatementForSqlObject(
        new InsertIgnore(table: 'acl_role')->values(['roleId' => 1, 'parentId' => '[]']),
    )->execute();
    Uncaught ValueError: mysqli_stmt::bind_param(): Argument #1 ($types) must not be empty
    at vendor/php-db/phpdb-mysql/src/Statement.php:233
    from bindParametersFromContainer() at Statement.php:68
    

    Reached on the mysqli driver: 'driver' => DriverInterface::class resolves through the ConfigProvider alias to PhpDb\Mysql\Driver. PDO does not hit it.

    Cause. The driver builds $type only from errata, but appends an argument for every parameter. Insert::processInsert() and Update::processUpdate(), scalar branch, call offsetSet($column, $value) with no errata, so $type ends up empty and bind_param('', ...) throws.

    Supporting: SqlInterface::TYPE_VALUE is declared and used nowhere in either package; 1ae5c59b and 86665115 replaced the TYPE_* constants with the ArgumentType enum; resolveColumnValue() sets no errata either. The scalar branch looks like it never got that plumbing.

    Fixes.

    A. In phpdb, set the type where the parameter is registered:

    $parameterContainer->offsetSet($column, $value, SqlInterface::TYPE_VALUE);

    in Insert::processInsert() and Update::processUpdate(), or route the scalar branch through ArgumentType::Value.

    B. In phpdb-mysql, default to 's' when a parameter carries no errata, so mysqli behaves like PDO. This also keeps hand-built ParameterContainers valid, which is what the tests do today.

    Not mutually exclusive. Worth also replacing the tests' errata workaround with a plain-array case, since that workaround kept the suite green while every real Insert/Update with scalar values failed.

    Impact: mysqli plus Insert/Update with scalar values, the ordinary path.

  4. linked a pull request that will close this issueFix argument count error #78on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions