Loading CHANGELOG.txt +2 −0 Changes for CHANGELOG.txt: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3247914 by drunken monkey: Fixed config form of the "Type-specific boosting" processor. - #3262702 by drunken monkey: Fixed test failures on Drupal 9.2. - #3227659 by drunken monkey, daften: Fixed double-escaped query parameters when using the Views "Preserve facets" option. Loading src/Plugin/search_api/processor/TypeBoost.php +7 −3 Changes for src/Plugin/search_api/processor/TypeBoost.php: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class TypeBoost extends ProcessorPluginBase implements PluginFormInterface { '' => $this->t('Use datasource default'), ] + $boost_factors; foreach ($this->index->getDatasources() as $datasource_id => $datasource) { $datasource_config = $datasource_configurations[$datasource_id]; $form['boosts'][$datasource_id] = [ '#type' => 'details', '#title' => $this->t('Boost settings for %datasource', ['%datasource' => $datasource->label()]), Loading @@ -67,7 +68,7 @@ class TypeBoost extends ProcessorPluginBase implements PluginFormInterface { '#title' => $this->t('Default boost for items from this datasource'), '#options' => $boost_factors, '#description' => $this->t('A boost of 1.00 is the default. Assign a boost of 0.00 to not score the item at all.'), '#default_value' => $datasource_configurations[$datasource_id]['datasource_boost'], '#default_value' => Utility::formatBoostFactor($datasource_config['datasource_boost']), ], ]; Loading @@ -80,9 +81,12 @@ class TypeBoost extends ProcessorPluginBase implements PluginFormInterface { unset($bundles[$datasource_id], $bundles[$datasource->getEntityTypeId()]); } $bundle_boosts = $datasource_configurations[$datasource_id]['bundle_boosts']; $bundle_boosts = $datasource_config['bundle_boosts']; foreach ($bundles as $bundle => $bundle_label) { $bundle_boost = Utility::formatBoostFactor($bundle_boosts[$bundle] ?? 0); $bundle_boost = $bundle_boosts[$bundle] ?? ''; if ($bundle_boost !== '') { $bundle_boost = Utility::formatBoostFactor($bundle_boost); } $form['boosts'][$datasource_id]['bundle_boosts'][$bundle] = [ '#type' => 'select', '#title' => $this->t('Boost for the %bundle bundle', ['%bundle' => $bundle_label]), Loading tests/src/Functional/ProcessorIntegrationTest.php +1 −0 Changes for tests/src/Functional/ProcessorIntegrationTest.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -456,6 +456,7 @@ class ProcessorIntegrationTest extends SearchApiBrowserTestBase { $form_values['boosts']['entity:node']['bundle_boosts']['page'] = ''; $this->editSettingsForm($configuration, 'type_boost', $form_values); $this->editSettingsForm($configuration, 'type_boost', []); } /** Loading tests/src/Kernel/Processor/TypeBoostTest.php +26 −5 Changes for tests/src/Kernel/Processor/TypeBoostTest.php: 26 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -133,13 +133,14 @@ class TypeBoostTest extends ProcessorTestBase { } /** * Tests that default values for individual bundles are correct in the form. * Tests that default values are correct in the config form. */ public function testConfigFormBundleBoostDefaults() { public function testConfigFormDefaultValues() { $form = $this->processor->buildConfigurationForm([], new FormState()); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(1), $form['boosts']['entity:node']['datasource_boost']['#default_value']); $this->assertEquals('', $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals('', $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $configuration = [ 'boosts' => [ Loading @@ -155,8 +156,28 @@ class TypeBoostTest extends ProcessorTestBase { $form = $this->processor->buildConfigurationForm([], new FormState()); $this->assertEquals(Utility::formatBoostFactor(3), $form['boosts']['entity:node']['datasource_boost']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $this->assertEquals('', $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $configuration = [ 'boosts' => [ 'entity:node' => [ 'datasource_boost' => Utility::formatBoostFactor(2), 'bundle_boosts' => [ 'article' => Utility::formatBoostFactor(3), 'page' => Utility::formatBoostFactor(1.5), ], ], ], ]; $this->processor->setConfiguration($configuration); $form = $this->processor->buildConfigurationForm([], new FormState()); $this->assertEquals(Utility::formatBoostFactor(2), $form['boosts']['entity:node']['datasource_boost']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(3), $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(1.5), $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); } } Loading
CHANGELOG.txt +2 −0 Changes for CHANGELOG.txt: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3247914 by drunken monkey: Fixed config form of the "Type-specific boosting" processor. - #3262702 by drunken monkey: Fixed test failures on Drupal 9.2. - #3227659 by drunken monkey, daften: Fixed double-escaped query parameters when using the Views "Preserve facets" option. Loading
src/Plugin/search_api/processor/TypeBoost.php +7 −3 Changes for src/Plugin/search_api/processor/TypeBoost.php: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class TypeBoost extends ProcessorPluginBase implements PluginFormInterface { '' => $this->t('Use datasource default'), ] + $boost_factors; foreach ($this->index->getDatasources() as $datasource_id => $datasource) { $datasource_config = $datasource_configurations[$datasource_id]; $form['boosts'][$datasource_id] = [ '#type' => 'details', '#title' => $this->t('Boost settings for %datasource', ['%datasource' => $datasource->label()]), Loading @@ -67,7 +68,7 @@ class TypeBoost extends ProcessorPluginBase implements PluginFormInterface { '#title' => $this->t('Default boost for items from this datasource'), '#options' => $boost_factors, '#description' => $this->t('A boost of 1.00 is the default. Assign a boost of 0.00 to not score the item at all.'), '#default_value' => $datasource_configurations[$datasource_id]['datasource_boost'], '#default_value' => Utility::formatBoostFactor($datasource_config['datasource_boost']), ], ]; Loading @@ -80,9 +81,12 @@ class TypeBoost extends ProcessorPluginBase implements PluginFormInterface { unset($bundles[$datasource_id], $bundles[$datasource->getEntityTypeId()]); } $bundle_boosts = $datasource_configurations[$datasource_id]['bundle_boosts']; $bundle_boosts = $datasource_config['bundle_boosts']; foreach ($bundles as $bundle => $bundle_label) { $bundle_boost = Utility::formatBoostFactor($bundle_boosts[$bundle] ?? 0); $bundle_boost = $bundle_boosts[$bundle] ?? ''; if ($bundle_boost !== '') { $bundle_boost = Utility::formatBoostFactor($bundle_boost); } $form['boosts'][$datasource_id]['bundle_boosts'][$bundle] = [ '#type' => 'select', '#title' => $this->t('Boost for the %bundle bundle', ['%bundle' => $bundle_label]), Loading
tests/src/Functional/ProcessorIntegrationTest.php +1 −0 Changes for tests/src/Functional/ProcessorIntegrationTest.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -456,6 +456,7 @@ class ProcessorIntegrationTest extends SearchApiBrowserTestBase { $form_values['boosts']['entity:node']['bundle_boosts']['page'] = ''; $this->editSettingsForm($configuration, 'type_boost', $form_values); $this->editSettingsForm($configuration, 'type_boost', []); } /** Loading
tests/src/Kernel/Processor/TypeBoostTest.php +26 −5 Changes for tests/src/Kernel/Processor/TypeBoostTest.php: 26 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -133,13 +133,14 @@ class TypeBoostTest extends ProcessorTestBase { } /** * Tests that default values for individual bundles are correct in the form. * Tests that default values are correct in the config form. */ public function testConfigFormBundleBoostDefaults() { public function testConfigFormDefaultValues() { $form = $this->processor->buildConfigurationForm([], new FormState()); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(1), $form['boosts']['entity:node']['datasource_boost']['#default_value']); $this->assertEquals('', $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals('', $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $configuration = [ 'boosts' => [ Loading @@ -155,8 +156,28 @@ class TypeBoostTest extends ProcessorTestBase { $form = $this->processor->buildConfigurationForm([], new FormState()); $this->assertEquals(Utility::formatBoostFactor(3), $form['boosts']['entity:node']['datasource_boost']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(0), $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $this->assertEquals('', $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); $configuration = [ 'boosts' => [ 'entity:node' => [ 'datasource_boost' => Utility::formatBoostFactor(2), 'bundle_boosts' => [ 'article' => Utility::formatBoostFactor(3), 'page' => Utility::formatBoostFactor(1.5), ], ], ], ]; $this->processor->setConfiguration($configuration); $form = $this->processor->buildConfigurationForm([], new FormState()); $this->assertEquals(Utility::formatBoostFactor(2), $form['boosts']['entity:node']['datasource_boost']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(3), $form['boosts']['entity:node']['bundle_boosts']['article']['#default_value']); $this->assertEquals(Utility::formatBoostFactor(1.5), $form['boosts']['entity:node']['bundle_boosts']['page']['#default_value']); } }