Commit bf238262 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Bug: adding Parameter '__dbIndex=X' broken under special situations.

parent c04152e3
......@@ -214,6 +214,9 @@ abstract class AbstractBuildForm {
}
} else {
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
if (!($recordId == '' || is_numeric($recordId))) {
throw new UserFormException('Invalid record ID: r="' . $recordId, '"', ERROR_INVALID_VALUE);
}
$htmlElements = $this->elements($recordId, $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero, $storeUse, $mode);
if ($mode === FORM_SAVE && $recordId != 0) {
......
......@@ -651,16 +651,21 @@ class Support {
* Concatenate URL and Parameter. Depending of if there is a '?' in URL or not, append the param with '?' or '&'..
*
* @param string $url
* @param string $param
* @param string|array $param
*
* @return string
*/
public static function concatUrlParam($url, $param) {
if (is_array($param)) {
$param = implode('&', $param);
}
if ($param == '') {
return $url;
}
$token = (strpos($url, '?') === false) ? '?' : '&';
$token = ((strpos($url, '?') === false) && (strpos($url, '&')) === false) ? '?' : '&';
return $url . $token . $param;
}
......
......@@ -795,9 +795,11 @@ class Link {
if ($vars[NAME_URL_PARAM] != '') {
$vars[NAME_URL_PARAM] .= '&';
}
$vars[NAME_URL_PARAM] .= PARAM_DB_INDEX_DATA . '=' . $this->dbIndexData;
}
// Normalize '?pagealias' to 'index.php?pagealias'
if (substr($vars[NAME_URL], 0, 1) === '?') {
$vars[NAME_URL] = INDEX_PHP . $vars[NAME_URL];
}
......
......@@ -362,23 +362,56 @@ class SupportTest extends \PHPUnit_Framework_TestCase {
$url = Support::concatUrlParam('', '');
$this->assertEquals('', $url);
$url = Support::concatUrlParam('', []);
$this->assertEquals('', $url);
$url = Support::concatUrlParam('', ['']);
$this->assertEquals('', $url);
$url = Support::concatUrlParam('http://example.com', '');
$this->assertEquals('http://example.com', $url);
$url = Support::concatUrlParam('http://example.com', []);
$this->assertEquals('http://example.com', $url);
$url = Support::concatUrlParam('http://example.com', ['']);
$this->assertEquals('http://example.com', $url);
$url = Support::concatUrlParam('', 'a=1');
$this->assertEquals('?a=1', $url);
$url = Support::concatUrlParam('', ['a=1']);
$this->assertEquals('?a=1', $url);
$url = Support::concatUrlParam('http://example.com', 'a=100');
$this->assertEquals('http://example.com?a=100', $url);
$url = Support::concatUrlParam('http://example.com', ['a=100']);
$this->assertEquals('http://example.com?a=100', $url);
$url = Support::concatUrlParam('http://example.com?id=2', 'a=100');
$this->assertEquals('http://example.com?id=2&a=100', $url);
$url = Support::concatUrlParam('http://example.com?id=2', ['a=100']);
$this->assertEquals('http://example.com?id=2&a=100', $url);
$url = Support::concatUrlParam('http://example.com', 'a=100&b=201');
$this->assertEquals('http://example.com?a=100&b=201', $url);
$url = Support::concatUrlParam('http://example.com', ['a=100&b=201']);
$this->assertEquals('http://example.com?a=100&b=201', $url);
$url = Support::concatUrlParam('http://example.com', ['a=100', 'b=201']);
$this->assertEquals('http://example.com?a=100&b=201', $url);
$url = Support::concatUrlParam('http://example.com?id=34', 'a=100&b=201');
$this->assertEquals('http://example.com?id=34&a=100&b=201', $url);
$url = Support::concatUrlParam('http://example.com?id=34', ['a=100&b=201']);
$this->assertEquals('http://example.com?id=34&a=100&b=201', $url);
$url = Support::concatUrlParam('http://example.com?id=34', ['a=100', 'b=201']);
$this->assertEquals('http://example.com?id=34&a=100&b=201', $url);
}
public function testSetIfNotSet() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment