facebook / facebook/hhvm

PDOStatement::debugDumpParams prints 's' instead of actual string values.

Open
#8,039 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

### HHVM Version
```
$ hhvm --version
HipHop VM 3.21.4-dev (rel)
Compiler: 1506490241_985323311
Repo schema: 77eb735cd6a728e0d1aa6ee4f99162cedbee71c5
```

### Standalone code, or other way to reproduce the problem

```
PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false
)
);

$pdo->exec('CREATE TABLE IF NOT EXISTS `test` (`id` INT)');
$query = $pdo->prepare('SELECT * FROM `test` WHERE `id` = :id');
$query->bindValue('id', 42, \PDO::PARAM_INT);
$query->debugDumpParams();
```

### Expected result

```
$ php pdo-debug.php
SQL: [37] SELECT * FROM `test` WHERE `id` = :id
Params: 1
Key: Name: [3] :id
paramno=-1
name=[3] ":id"
is_param=1
param_type=1
```

### Actual result

```
$ hhvm pdo-debug.php
SQL: [37] s
Params: 1
Key: Name: [3] s
paramno=-1
name=[3] "s"
is_param=0
param_type=1
```

https://github.com/facebook/hhvm/blob/93f5998d4de5978484d18cc2b9ed314a00aff9b8/hphp/runtime/ext/pdo/ext_pdo.cpp#L3228

Pretty sure "%.*s" modifier isn't supported in string_sprintf, but I don't know enough about HHVM's string representation to know the fix (are they null-terminated? does string_sprintf assume null termination?):

https://github.com/facebook/hhvm/blob/93f5998d4de5978484d18cc2b9ed314a00aff9b8/hphp/runtime/base/zend-printf.cpp#L793

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.