Permalink
Browse files

Fix routing prefix, value & postfix to be null if not present

Previously those were set to an empty string
  • Loading branch information...
thomasbachem committed Jan 5, 2016
1 parent c7023d6 commit bae9934f27ac5a1b39efea51bcb689c995214e94
Showing with 16 additions and 13 deletions.
  1. +1 −0 CHANGELOG
  2. +5 −0 UPGRADING
  3. +10 −13 src/routing/AgaviRouting.class.php
View
@@ -83,5 +83,6 @@ FIX: <exclude> in suites.xml files is broken (#1525) (Dominik)
FIX: fix AgaviViewTestCase::assertViewSetsCookie throwing a notice (#1521) (Dominik)
FIX: Fix "session_id" parameter of AgaviSessionStorage (#1479) (Thomas Bachem)
FIX: Routing default values can now be zero or an empty string (#1545) (Thomas Bachem)
FIX: BREAKING CHANGE: Prefix, value & postfix of routing values do now default to null instead of an empty string if not present (#1570) (Thomas Bachem)
FIX: BREAKING CHANGE: <filters> element in translation.xml doesn't allow multiple <filter> child elements (#1475) (Dominik, Armin Rezayati)
FIX: BREAKING CHANGE: XML entities in configuration files are now properly substituted everywhere (#1571) (Thomas Bachem)
View
@@ -36,6 +36,11 @@ Logging
-------
We added a getLevel() method to AgaviLogger and the AgaviILogger interface. This may break your code if you're using the AgaviILogger interface or have added a custom getLevel() method to classes inheriting from AgaviLogger.
Routing
-------
Prefix, value & postfix of routing values do now default to null instead of an empty string if not present. This may break your code if you're e.g. checking default values in routing callbacks and expect them to be empty strings.
Testing
-------
The PHPUnit minimum requirement has been updated to 3.7.
@@ -1563,10 +1563,10 @@ protected function parseRouteString($str)
$tmpStr = '';
$inEscape = false;
$rxName = '';
$rxInner = '';
$rxPrefix = '';
$rxPostfix = '';
$rxName = null;
$rxInner = null;
$rxPrefix = null;
$rxPostfix = null;
$parenthesisCount = 0;
$bracketCount = 0;
$hasBrackets = false;
@@ -1606,7 +1606,7 @@ protected function parseRouteString($str)
$tmpStr = '';
$state = 'rxStart';
$rxName = $rxInner = $rxPrefix = $rxPostfix = '';
$rxName = $rxInner = $rxPrefix = $rxPostfix = null;
$parenthesisCount = 1;
$bracketCount = 0;
$hasBrackets = false;
@@ -1671,13 +1671,13 @@ protected function parseRouteString($str)
if(!isset($vars[$rxName])) {
if(strpbrk($rxPrefix, $rxChars) !== false) {
$rxPrefix = '';
$rxPrefix = null;
}
if(strpbrk($rxInner, $rxChars) !== false) {
$rxInner = '';
$rxInner = null;
}
if(strpbrk($rxPostfix, $rxChars) !== false) {
$rxPostfix = '';
$rxPostfix = null;
}
$vars[$rxName] = array('pre' => $rxPrefix, 'val' => $rxInner, 'post' => $rxPostfix, 'is_optional' => false);
@@ -1726,11 +1726,8 @@ protected function parseRouteString($str)
*/
protected function parseParameterDefinition($def)
{
$name = '';
$rx = '';
preg_match('#([a-z0-9_-]+:)?(.*)#i', $def, $match);
return array(substr($match[1], 0, -1), $match[2]);
preg_match('#(?:([a-z0-9_-]+):)?(.*)#i', $def, $match);
return array($match[1] !== '' ? $match[1] : null, $match[2]);
}
/**

0 comments on commit bae9934

Please sign in to comment.