Commit 3f52754e authored by catch's avatar catch

Issue #2718717 by damiankloip: Assertion error when paging a view using an...

Issue #2718717 by damiankloip: Assertion error when paging a view using an entity autocomplete exposed filter
parent 4ad7ddb3
......@@ -373,7 +373,8 @@ protected function viewsTokenReplace($text, $tokens) {
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.');
$token_array = array(array_pop($parts) => $replacement);
foreach (array_reverse($parts) as $key) {
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1', 'Tokens need to be valid Twig variables.');
// The key could also be numeric (array index) so allow that.
assert('is_numeric($key) || (preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1)', 'Tokens need to be valid Twig variables.');
$token_array = array($key => $token_array);
}
if (!isset($twig_tokens[$top])) {
......
......@@ -55,6 +55,16 @@ public function testViewsTokenReplaceWithDots() {
});
$this->assertIdentical($result, 'first comes before second');
// Test tokens with numeric indexes.
$text = '{{ argument.0.first }} comes before {{ argument.1.second }}';
$tokens = ['{{ argument.0.first }}' => 'first', '{{ argument.1.second }}' => 'second'];
$result = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($text, $tokens) {
return $this->testPluginBase->viewsTokenReplace($text, $tokens);
});
$this->assertIdentical($result, 'first comes before second');
}
/**
......
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