Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
facets
Commits
05498e44
Commit
05498e44
authored
Mar 24, 2016
by
Joris Vercammen
Committed by
Joris Vercammen
Mar 24, 2016
Browse files
Issue
#2656010
by borisson_: Query string url processor can't handle a colon in the value
parent
196a64e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Plugin/facets/url_processor/QueryString.php
View file @
05498e44
...
...
@@ -153,7 +153,15 @@ class QueryString extends UrlProcessorPluginBase {
// Explode the active params on the separator.
foreach
(
$active_params
as
$param
)
{
list
(
$key
,
$value
)
=
explode
(
self
::
SEPARATOR
,
$param
,
2
);
$explosion
=
explode
(
self
::
SEPARATOR
,
$param
);
$key
=
array_shift
(
$explosion
);
$value
=
''
;
while
(
count
(
$explosion
)
>
0
)
{
$value
.
=
array_shift
(
$explosion
);
if
(
count
(
$explosion
)
>
0
)
{
$value
.
=
self
::
SEPARATOR
;
}
}
if
(
!
isset
(
$this
->
activeFilters
[
$key
]))
{
$this
->
activeFilters
[
$key
]
=
[
$value
];
}
...
...
src/Tests/UrlIntegrationTest.php
View file @
05498e44
...
...
@@ -131,6 +131,69 @@ class UrlIntegrationTest extends WebTestBase {
$this
->
checkClickedFacetUrl
(
$url_3
);
}
/**
* Tests the url when a colon is used in the value.
*/
public
function
testColonValue
()
{
$id
=
'water_bear'
;
$url_alias
=
'bear'
;
$name
=
'Water bear'
;
$facet_add_page
=
'admin/config/search/facets/add-facet'
;
// Create the facet.
$this
->
drupalGet
(
$facet_add_page
);
$form_values
=
[
'id'
=>
$id
,
'status'
=>
1
,
'url_alias'
=>
$url_alias
,
'name'
=>
$name
,
'weight'
=>
1
,
'facet_source_id'
=>
'search_api_views:search_api_test_view:page_1'
,
'facet_source_configs[search_api_views:search_api_test_view:page_1][field_identifier]'
=>
'keywords'
,
];
$this
->
drupalPostForm
(
NULL
,
[
'facet_source_id'
=>
'search_api_views:search_api_test_view:page_1'
],
$this
->
t
(
'Configure facet source'
));
$this
->
drupalPostForm
(
NULL
,
$form_values
,
$this
->
t
(
'Save'
));
// Create / place the block.
$block_settings
=
[
'region'
=>
'footer'
,
'id'
=>
str_replace
(
'_'
,
'-'
,
$id
),
];
$this
->
drupalPlaceBlock
(
'facet_block:'
.
$id
,
$block_settings
);
// Add a new entity that has a colon in one of it's keywords.
$entity_test_storage
=
\
Drupal
::
entityTypeManager
()
->
getStorage
(
'entity_test'
);
$entity_test_storage
->
create
([
'name'
=>
'Entity with colon'
,
'body'
=>
'test test'
,
'type'
=>
'item'
,
'keywords'
=>
[
'orange'
,
'test:colon'
],
'category'
=>
'item_category'
,
])
->
save
();
// Make sure the new item is indexed.
$this
->
assertEqual
(
1
,
$this
->
indexItems
(
$this
->
indexId
));
// Go to the overview and test that we have the expected links.
$this
->
drupalGet
(
'search-api-test-fulltext'
);
$this
->
assertLink
(
'test:colon'
);
$this
->
assertLink
(
'orange'
);
$this
->
assertLink
(
'banana'
);
// Click the link with the colon.
$this
->
clickLink
(
'test:colon'
);
$this
->
assertResponse
(
200
);
// Make sure 'test:colon' is active.
$url
=
Url
::
fromUserInput
(
'/search-api-test-fulltext'
,
[
'query'
=>
[
'f[0]'
=>
'bear:test:colon'
]]);
$this
->
assertUrl
(
$url
);
$this
->
assertLink
(
'(-) test:colon'
);
$this
->
assertLink
(
'orange'
);
$this
->
assertLink
(
'banana'
);
}
/**
* Checks that the url after clicking a facet is as expected.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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