Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bridge] [Doctrine] Normalize params only when used. [2.3] #17364

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ public function startQuery($sql, array $params = null, array $types = null)
$this->stopwatch->start('doctrine', 'doctrine');
}

if (is_array($params)) {
$params = $this->normalizeParams($params);
}

if (null !== $this->logger) {
$this->log($sql, null === $params ? array() : $params);
$this->log($sql, null === $params ? array() : $this->normalizeParams($params));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if $params is no array (this was checked before)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $params is not an array and not null; PHP will raise a fatal error because the function signature states array (with default null).

sth like;

PHP Catchable fatal error:  Argument 2 passed to startQuery() must be of the type array, integer given, ...

so the test for array and later on for null was overcomplete AFAIK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that $params can indeed be null here but normalizeParams() doesn't handle null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $params is null it is not given to normalizeParams, I'm not sure if I follow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I missed the null === $params check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for the review :)

}
}

Expand Down