Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
2db071c4
Commit
2db071c4
authored
Dec 09, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for empty params (needed for the 'q' param in dismax to use 'q.alt')
parent
0b4e71f8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
library/Solarium/Client/Request.php
library/Solarium/Client/Request.php
+1
-1
tests/Solarium/Client/RequestTest.php
tests/Solarium/Client/RequestTest.php
+12
-6
No files found.
library/Solarium/Client/Request.php
View file @
2db071c4
...
@@ -211,7 +211,7 @@ class Solarium_Client_Request extends Solarium_Configurable
...
@@ -211,7 +211,7 @@ class Solarium_Client_Request extends Solarium_Configurable
*/
*/
public
function
addParam
(
$key
,
$value
,
$overwrite
=
false
)
public
function
addParam
(
$key
,
$value
,
$overwrite
=
false
)
{
{
if
(
$value
!==
''
&&
$value
!==
null
)
{
if
(
$value
!==
null
)
{
if
(
!
$overwrite
&&
isset
(
$this
->
_params
[
$key
]))
{
if
(
!
$overwrite
&&
isset
(
$this
->
_params
[
$key
]))
{
if
(
!
is_array
(
$this
->
_params
[
$key
]))
{
if
(
!
is_array
(
$this
->
_params
[
$key
]))
{
$this
->
_params
[
$key
]
=
array
(
$this
->
_params
[
$key
]);
$this
->
_params
[
$key
]
=
array
(
$this
->
_params
[
$key
]);
...
...
tests/Solarium/Client/RequestTest.php
View file @
2db071c4
...
@@ -212,17 +212,23 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
...
@@ -212,17 +212,23 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
{
{
$params
=
array
(
$params
=
array
(
'param1'
=>
1
,
'param1'
=>
1
,
'param2'
=>
2
,
'param3'
=>
3
,
);
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
addParam
(
'param2'
,
2
);
$this
->
_request
->
addParam
(
'param2'
,
''
);
// this should add an empty value to param2
$this
->
_request
->
addParam
(
'param2'
,
''
);
$this
->
_request
->
addParam
(
'param3'
,
''
,
true
);
// this should overwrite param2 with an empty value
$this
->
_request
->
addParam
(
'param3'
,
''
);
$this
->
_request
->
addParam
(
'param4'
,
''
);
// this should add an empty param (for instance "q=" in dismax)
$this
->
_request
->
addParam
(
'param5'
,
null
);
// this param should be ignored
$params
[
'param2'
]
=
2
;
$this
->
assertEquals
(
$this
->
assertEquals
(
$params
,
array
(
'param1'
=>
1
,
'param2'
=>
array
(
2
,
''
),
'param3'
=>
''
,
'param4'
=>
''
,
),
$this
->
_request
->
getParams
()
$this
->
_request
->
getParams
()
);
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment