Browse files

Fix handling of NULLs when replacing query params

  • Loading branch information...
1 parent d29d852 commit 831c76f36e4449ebd2d067daa60375f97e446049 @lazyhammer committed Mar 13, 2013
Showing with 6 additions and 2 deletions.
  1. +6 −2 Twig/DoctrineExtension.php
View
8 Twig/DoctrineExtension.php
@@ -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)) {
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++;

0 comments on commit 831c76f

Please sign in to comment.