mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [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:
commit
af10ca630d
2 changed files with 48 additions and 3 deletions
|
@ -316,7 +316,7 @@ class path_helper
|
||||||
* Glue URL parameters together
|
* Glue URL parameters together
|
||||||
*
|
*
|
||||||
* @param array $params URL parameters in the form of array(name => value)
|
* @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)
|
public function glue_url_params($params)
|
||||||
{
|
{
|
||||||
|
@ -324,7 +324,15 @@ class path_helper
|
||||||
|
|
||||||
foreach ($params as $key => $value)
|
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);
|
return implode('&', $_params);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +361,17 @@ class path_helper
|
||||||
{
|
{
|
||||||
continue;
|
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 === '')
|
if ($key === '')
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,6 +205,18 @@ class phpbb_path_helper_test extends phpbb_test_case
|
||||||
array('test' => 'xyz', 'var' => 'value'),
|
array('test' => 'xyz', 'var' => 'value'),
|
||||||
'test=xyz&var=value',
|
'test=xyz&var=value',
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
array('test' => null),
|
||||||
|
'test',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('test' => null, 'var' => null),
|
||||||
|
'test&var',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('test' => 'xyz', 'var' => null, 'bar' => 'value'),
|
||||||
|
'test=xyz&var&bar=value',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +266,21 @@ class phpbb_path_helper_test extends phpbb_test_case
|
||||||
true,
|
true,
|
||||||
array('base' => 'mcp.php', 'params' => array('f' => '3')),
|
array('base' => 'mcp.php', 'params' => array('f' => '3')),
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'index.php?ready',
|
||||||
|
false,
|
||||||
|
array('base' => 'index.php', 'params' => array('ready' => null)),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'index.php?i=1&ready',
|
||||||
|
true,
|
||||||
|
array('base' => 'index.php', 'params' => array('i' => '1', 'ready' => null)),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'index.php?ready&i=1',
|
||||||
|
false,
|
||||||
|
array('base' => 'index.php', 'params' => array('ready' => null, 'i' => '1')),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue