Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v9.17.0.300] [workaround found] ErrorException: Warning: PDOStatement::bindParam(): Argument #2 ($var) must be passed by reference, value given #143

Closed
ruudk opened this issue Apr 22, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@ruudk
Copy link

ruudk commented Apr 22, 2021

Description

I just deployed the latest agent on PHP 8.0.3 and am getting this exception that I cannot explain:

ErrorException: Warning: PDOStatement::bindParam(): Argument #2 ($var) must be passed by reference, value given
#16 /vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(112): Doctrine\DBAL\Driver\PDOStatement::execute
#15 /vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1292): Doctrine\DBAL\Connection::executeQuery
#14 /vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(44): Doctrine\ORM\Query\Exec\SingleSelectExecutor::execute
#13 /vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(325): Doctrine\ORM\Query::_doExecute
#12 /vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(1073): Doctrine\ORM\AbstractQuery::executeIgnoreQueryCache
#11 /vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(1027): Doctrine\ORM\AbstractQuery::execute
#10 /vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(791): Doctrine\ORM\AbstractQuery::getResult

My first thought was that this is related to Doctrine DBAL/ORM but then I searched for bindParam in the agent code and found:

void nr_php_pdo_rebind_parameters(zval* source, zval* destination TSRMLS_DC) {
pdo_stmt_t* pdo_stmt = nr_php_pdo_get_statement_object(source TSRMLS_CC);
/*
* For each parameter, we want to call bindParam with the original zval (so
* that by-reference parameters are correctly handled).
*/
if ((NULL != pdo_stmt) && (NULL != pdo_stmt->bound_params)) {
nr_php_zend_hash_ptr_apply(
pdo_stmt->bound_params,
(nr_php_ptr_apply_t)nr_php_pdo_rebind_apply_parameter,
destination TSRMLS_CC);
}
}

Could it be related to this?

The Doctrine code passes it correctly via reference.

Your Environment

Ubuntu PHP 8.0.3

Additional context

I'm using the latest Doctrine DBAL/ORM:

composer show | grep "doctrine/"
broadway/event-store-dbal               0.5.0              Event store implementation using doctrine/dbal
doctrine/annotations                    1.12.1             Docblock Annotations Parser
doctrine/cache                          1.10.2             PHP Doctrine Cache library is a popular cache implementation th...
doctrine/collections                    1.6.7              PHP Doctrine Collections library that adds additional functiona...
doctrine/common                         3.1.2              PHP Doctrine Common project is a library that provides addition...
doctrine/data-fixtures                  1.5.0              Data Fixtures for all Doctrine Object Managers
doctrine/dbal                           2.13.1             Powerful PHP database abstraction layer (DBAL) with many featur...
doctrine/deprecations                   v0.5.3             A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR...
doctrine/doctrine-bundle                2.3.1              Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle       3.4.0              Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle     3.1.1              Symfony DoctrineMigrationsBundle
doctrine/event-manager                  1.1.1              The Doctrine Event Manager is a simple PHP event system that wa...
doctrine/inflector                      2.0.3              PHP Doctrine Inflector is a small library that can perform stri...
doctrine/instantiator                   1.4.0              A small, lightweight utility to instantiate objects in PHP with...
doctrine/lexer                          1.2.1              PHP Doctrine Lexer parser library that can be used in Top-Down,...
doctrine/migrations                     3.1.1              PHP Doctrine Migrations project offer additional functionality ...
doctrine/orm                            2.8.4              Object-Relational-Mapper for PHP
doctrine/persistence                    2.1.0              The Doctrine Persistence project is a set of shared interfaces ...
doctrine/sql-formatter                  1.1.1              a PHP SQL highlighting library
@ruudk ruudk added the bug Something isn't working label Apr 22, 2021
@ruudk ruudk changed the title [v9.17.0.300] ErrorException: Warning: PDOStatement::bindParam(): Argument #2 ($var) must be passed by reference, value given [v9.17.0.300] [workaround found] ErrorException: Warning: PDOStatement::bindParam(): Argument #2 ($var) must be passed by reference, value given Apr 22, 2021
@ruudk
Copy link
Author

ruudk commented Apr 22, 2021

If you set newrelic.transaction_tracer.explain_enabled = false the error goes away. That proofs that the referenced code in the OP is the cause of this.

@joshuabenuck
Copy link
Contributor

@ruudk Thanks for the detailed issue report and for the information on the workaround! It really helps narrow down where the problem may be. We are working on reproducing this locally.

@Fahmy-Mohammed Fahmy-Mohammed added this to Triage - tag + prioritize. in PHP/C Engineering Board via automation Apr 22, 2021
@Fahmy-Mohammed Fahmy-Mohammed moved this from Triage - tag + prioritize. to To Do - Issues that are committed and up next. in PHP/C Engineering Board Apr 22, 2021
@joshuabenuck
Copy link
Contributor

I was able to reproduce the problem. I have a work in progress PR exploring the best way to fix this as it touches on a PHP 8 API change that impacts other parts of the code. What we do here will establish the pattern we need to follow in future similar scenarios. My first attempt looks to have been too general so it will need to be reworked.

@joshuabenuck
Copy link
Contributor

The revised fix (with automated test) has been merged. It will be in the next release.

@kneitinger
Copy link
Contributor

Hi all,

We just put out a patch release (9.17.1) that addresses this issue! We'll leave this issue open for a few days to verify that this solution is working well for folks, so please feel free to leave any feedback about your experience! Thanks!

@ruudk
Copy link
Author

ruudk commented Apr 29, 2021

Deployed 9.17.1.301 to production and enabled the Explain Tracer again. It works 🎉 Thanks.

@ruudk ruudk closed this as completed Apr 29, 2021
PHP/C Engineering Board automation moved this from To Do - Issues that are committed and up next. to Done Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

3 participants