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

Already on GitHub? Sign in to your account

Fix handling of NULLs when replacing query params #169

Merged
merged 1 commit into from Oct 12, 2013
Jump to file or symbol
Failed to load files and symbols.
+6 −2
Split
@@ -269,6 +269,10 @@ static public function escapeFunction($parameter)
case is_object($result) :
$result = addslashes((string) $result);
break;
+
+ case null === $result :
+ $result = 'NULL';
+ break;
}
return $result;
@@ -290,11 +294,11 @@ public function replaceQueryParameters($query, $parameters)
'/\?|(:[a-z0-9_]+)/i',
function ($matches) use ($parameters, &$i) {
$key = substr($matches[0], 1);
- if (!isset($parameters[$i]) && !isset($parameters[$key])) {
+ if (!array_key_exists($i, $parameters) && !array_key_exists($key, $parameters)) {
@Baachi

Baachi Mar 14, 2013

Is this change really necessary?

@lazyhammer

lazyhammer Mar 14, 2013

Contributor

Try something like replaceQueryParameters('?, ?', array(1, null)) or replaceQueryParameters('?, ?', array(null, 1)) and you'll see :)

return $matches[0];
}
- $value = isset($parameters[$i]) ? $parameters[$i] : $parameters[$key];
+ $value = array_key_exists($i, $parameters) ? $parameters[$i] : $parameters[$key];
$result = DoctrineExtension::escapeFunction($value);
$i++;