Skip to content

Commit

Permalink
fix PDO instrumentation in PHP 8.4
Browse files Browse the repository at this point in the history
PHP 8.4 includes implementation of PDO driver specific sub-classes RFC
(see https://wiki.php.net/rfc/pdo_driver_specific_subclasses). This
means that when database access code uses new factory method
`PDO::connect` to create PDO object, an instance of driver specific
sub-class of `PDO` is returned instead of an instance of generic `PDO`
class. This means that instrumentation of generic `PDO` class is not
enough to provide instrumentation of datastores. Add wrappers for driver
specific subclasses of `PDO` supported by the agent: `Pdo\Firebird`,
`Pdo\Mysql`, `Pdo\Odbc`, `Pdo\Pgsql`, `Pdo\Sqlite`.
  • Loading branch information
lavarou committed Dec 12, 2024
1 parent e49aee5 commit dcc238f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions agent/php_internal_instrument.c
Original file line number Diff line number Diff line change
Expand Up @@ -3840,9 +3840,37 @@ void nr_php_generate_internal_wrap_records(void) {
NR_INTERNAL_WRAPREC("sqlite3::exec", sqlite3_exec, sqlite3, 0, 0)

NR_INTERNAL_WRAPREC("pdo::__construct", pdo_construct, pdo_construct, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::__construct", pdo_construct, pdo_construct, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::__construct", pdo_construct, pdo_construct, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdo::query", pdo_query, pdo_query, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::query", pdo_query, pdo_query, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::query", pdo_query, pdo_query, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdo::exec", pdo_exec, pdo_exec, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::exec", pdo_exec, pdo_exec, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::exec", pdo_exec, pdo_exec, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdo::prepare", pdo_prepare, pdo_prepare, 0, 0)
#if ZEND_MODULE_API_NO >= ZEND_8_4_X_API_NO
NR_INTERNAL_WRAPREC("pdo\\firebird::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\mysql::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\odbc::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\pgsql::prepare", pdo_prepare, pdo_prepare, 0, 0)
NR_INTERNAL_WRAPREC("pdo\\sqlite::prepare", pdo_prepare, pdo_prepare, 0, 0)
#endif
NR_INTERNAL_WRAPREC("pdostatement::execute", pdostmt_execute,
pdostatement_execute, 0, 0)

Expand Down

0 comments on commit dcc238f

Please sign in to comment.