1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #2919 from Senky/ticket/12852

[ticket/12852] Make get_url_parts handle get variable with no value

* Senky/ticket/12852:
  [ticket/12852] Add unit tests
  [ticket/12852] Add space after if
  [ticket/12852] Remove whitespace
  [ticket/12852] Make get_url_parts handle get variable with no value
This commit is contained in:
Tristan Darricau
2014-09-06 15:47:30 +02:00
2 changed files with 48 additions and 3 deletions

View File

@@ -316,7 +316,7 @@ class path_helper
* Glue URL parameters together
*
* @param array $params URL parameters in the form of array(name => value)
* @return string Returns the glued string, e.g. name1=value1&name2=value2
* @return string Returns the glued string, e.g. name1=value1&name2&name3=value3
*/
public function glue_url_params($params)
{
@@ -324,7 +324,15 @@ class path_helper
foreach ($params as $key => $value)
{
$_params[] = $key . '=' . $value;
// some parameters do not have value
if ($value !== null)
{
$_params[] = $key . '=' . $value;
}
else
{
$_params[] = $key;
}
}
return implode('&', $_params);
}
@@ -353,7 +361,17 @@ class path_helper
{
continue;
}
list($key, $value) = explode('=', $argument, 2);
// some parameters don't have value
if (strpos($argument, '=') !== false)
{
list($key, $value) = explode('=', $argument, 2);
}
else
{
$key = $argument;
$value = null;
}
if ($key === '')
{