forked from GNUsocial/gnu-social
[URLMAPPER] Fix small bug in URLMapper: a dynamic route might not exist even if a static one does
This commit is contained in:
parent
10b3b343dd
commit
6d81848f25
@ -169,60 +169,62 @@ class URLMapper
|
|||||||
throw new Exception(sprintf('No candidate paths for action "%s"', $action));
|
throw new Exception(sprintf('No candidate paths for action "%s"', $action));
|
||||||
}
|
}
|
||||||
|
|
||||||
$candidates = $this->reverse_dynamics[$action];
|
if (array_key_exists($action, $this->reverse_dynamics)){
|
||||||
|
$candidates = $this->reverse_dynamics[$action];
|
||||||
|
foreach ($candidates as $candidate) {
|
||||||
|
list($tryArgs, $format, $paramNames) = $candidate;
|
||||||
|
|
||||||
foreach ($candidates as $candidate) {
|
foreach ($tryArgs as $key => $value) {
|
||||||
list($tryArgs, $format, $paramNames) = $candidate;
|
if (!array_key_exists($key, $args) || $args[$key] != $value) {
|
||||||
|
// next candidate
|
||||||
foreach ($tryArgs as $key => $value) {
|
continue 2;
|
||||||
if (!array_key_exists($key, $args) || $args[$key] != $value) {
|
}
|
||||||
// next candidate
|
|
||||||
continue 2;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// success
|
// success
|
||||||
$toFormat = [];
|
$toFormat = [];
|
||||||
|
|
||||||
foreach ($paramNames as $name) {
|
foreach ($paramNames as $name) {
|
||||||
if (!array_key_exists($name, $args)) {
|
if (!array_key_exists($name, $args)) {
|
||||||
// next candidate
|
// next candidate
|
||||||
continue 2;
|
continue 2;
|
||||||
|
}
|
||||||
|
$toFormat[] = $args[$name];
|
||||||
}
|
}
|
||||||
$toFormat[] = $args[$name];
|
|
||||||
|
$path = vsprintf($format, $toFormat);
|
||||||
|
|
||||||
|
if (!empty($qstring)) {
|
||||||
|
$formatted = http_build_query($qstring);
|
||||||
|
$path .= '?' . $formatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = vsprintf($format, $toFormat);
|
|
||||||
|
|
||||||
if (!empty($qstring)) {
|
|
||||||
$formatted = http_build_query($qstring);
|
|
||||||
$path .= '?' . $formatted;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$candidates = $this->reverse_statics[$action];
|
if (array_key_exists($action, $this->reverse_statics)) {
|
||||||
|
$candidates = $this->reverse_statics[$action];
|
||||||
|
foreach ($candidates as $candidate) {
|
||||||
|
list($tryArgs, $tryPath) = $candidate;
|
||||||
|
|
||||||
foreach ($candidates as $candidate) {
|
foreach ($tryArgs as $key => $value) {
|
||||||
list($tryArgs, $tryPath) = $candidate;
|
if (!array_key_exists($key, $args) || $args[$key] != $value) {
|
||||||
|
// next candidate
|
||||||
foreach ($tryArgs as $key => $value) {
|
continue 2;
|
||||||
if (!array_key_exists($key, $args) || $args[$key] != $value) {
|
}
|
||||||
// next candidate
|
|
||||||
continue 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// success
|
||||||
|
$path = $tryPath;
|
||||||
|
|
||||||
|
if (!empty($qstring)) {
|
||||||
|
$formatted = http_build_query($qstring);
|
||||||
|
$path .= '?' . $formatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// success
|
|
||||||
$path = $tryPath;
|
|
||||||
|
|
||||||
if (!empty($qstring)) {
|
|
||||||
$formatted = http_build_query($qstring);
|
|
||||||
$path .= '?' . $formatted;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// failure; some reporting twiddles
|
// failure; some reporting twiddles
|
||||||
|
Loading…
Reference in New Issue
Block a user