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

fix(agent): don't skip arguments when calling mysqli::real_connect #976

Merged
merged 7 commits into from
Oct 18, 2024

Conversation

lavarou
Copy link
Member

@lavarou lavarou commented Oct 14, 2024

No description provided.

@lavarou lavarou self-assigned this Oct 14, 2024
@newrelic-php-agent-bot
Copy link

newrelic-php-agent-bot commented Oct 14, 2024

Test Suite Status Result
Multiverse 7/7 passing
SOAK 56/56 passing

@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.54%. Comparing base (597bad6) to head (b1c7ab5).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #976   +/-   ##
=======================================
  Coverage   78.54%   78.54%           
=======================================
  Files         196      196           
  Lines       27103    27103           
=======================================
  Hits        21287    21287           
  Misses       5816     5816           
Flag Coverage Δ
agent-for-php-7.2 78.55% <100.00%> (ø)
agent-for-php-7.3 78.57% <100.00%> (ø)
agent-for-php-7.4 78.27% <100.00%> (ø)
agent-for-php-8.0 78.29% <100.00%> (ø)
agent-for-php-8.1 78.28% <100.00%> (ø)
agent-for-php-8.2 77.87% <100.00%> (ø)
agent-for-php-8.3 77.87% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

lavarou and others added 4 commits October 15, 2024 17:34
Allow connecting to mysqldb via socket.
Test slowsql functionality when mysqldb is accessed via socket.
When one of the arguments in nr_php_mysqli_link_real_connect is
null, the entire argument is skipped. This causes a fatal error
when attempting to connect to a database through a Unix socket,
without specifying a port number.

This change ensures all arguments are passed on to real_connect
in the correct order, including any nulls.
The correct default for the $flags argument is 0, not null. Passing a
null causes a warning.
agent/php_mysqli.c Outdated Show resolved Hide resolved
Part of the problem is that argc in the function previously only incremented for non-null parameters, so it's throwing the count off when we are using it in if statements.  Additionally, for our instrumentation to work, the first three parameters should only be added if they are non-null (note the comment that exists before adding the remaining params). So we need to keep track of the required first three in addition to all other arguments that are being added.  We also need the count of the required parameters so that we can properly assess whether we need to do call call mysqli::select_db. We can handle this with an additional param to specify whether a value should be added as an arg if it is set or not set.
agent/php_mysqli.c Outdated Show resolved Hide resolved
agent/php_mysqli.c Outdated Show resolved Hide resolved
* changed is_set to null_ok
* removed extra check on flags since we can specify null_ok to false.
@zsistla zsistla marked this pull request as ready for review October 17, 2024 15:17
@zsistla zsistla merged commit dc162a4 into dev Oct 18, 2024
55 checks passed
@ZNeumann ZNeumann added this to the next-release milestone Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants