Closed alexborton closed 6 years ago
This is because when using the multi domain bundle you must specify your full locales, e.g. en_us, en_gb, fr_fr etc.
These locales are not defined by the analyzer_languages.yml
config file in the SearchBundle hence the undefined index problems.
This file can be overridden in your site bundle where you can add in the extra locales.
Would you want us to submit a pull request with more locales added to the file or is it expected that this file should be overridden if more locales are required, it may need adding to the documentation for the multi domain bundle?
I am convinced we have to write documentation for it. We should always strive to have every single configurable thing documented. It would be nice to add more locales to the analyzer_languages.yml but I think it will never be complete enough that we should not document the possibility to configure it. Could you make a PR that adds some documentation to the multi domain bundle?
I actually have some free time on my hands at the moment so I will take care of this.
I can send over exactly what we did to override it next week if that is any help?
That would be helpful yes. Thanks for that.
We just changed the Extension class in our Bundle to:
class MyProjectExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
if (!array_key_exists('analyzer_languages', $config) or count($config['analyzer_languages']) <= 0) {
$config['analyzer_languages'] = $this->getDefaultAnalyzerLanguages();
}
$container->setParameter('analyzer_languages', $config['analyzer_languages']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
public function getDefaultAnalyzerLanguages()
{
return Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/analyzer_languages.yml'));
}
}
and copied the analyzer_languages.yml
from the SearchBundle Resources, adding in any locales needed.
Error messages more clear because #1635 and no more crashes
When setting up the search for a multi-domain website, both setup commands error.
kuma:search:setup returns
app.ERROR: Symfony\Component\Debug\Exception\ContextErrorException: Notice: Undefined index: en_us (uncaught exception) at /Users/alex/Sites/*WEBSITE*/vendor/kunstmaan/bundles-cms/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php line 141 while running console command
kuma:search:setup{"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Notice: Undefined index: en_us at /Users/alex/Sites/*WEBSITE*/vendor/kunstmaan/bundles-cms/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php:141)"} {"file":"/Users/alex/Sites/*WEBSITE*/vendor/kunstmaan/bundles-cms/src/Kunstmaan/AdminBundle/EventListener/ConsoleExceptionListener.php","line":28,"class":"Kunstmaan\\AdminBundle\\EventListener\\ConsoleExceptionListener","function":"onConsoleException"}
Probably linked to that, the populate function also returns an error of a missing index;
app.ERROR: Elastica\Exception\ResponseException: IndexMissingException[[*WEBSITE*nodeindex_en_us] missing] (uncaught exception) at /Users/alex/Sites/*WEBSITE*/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php line 170 while running console command
kuma:search:populate{"exception":"[object] (Elastica\\Exception\\ResponseException(code: 0): IndexMissingException[[*WEBSITE*nodeindex_en_us] missing] at /Users/alex/Sites/*WEBSITE*/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php:170)"} {"file":"/Users/alex/Sites/*WEBSITE*/vendor/kunstmaan/bundles-cms/src/Kunstmaan/AdminBundle/EventListener/ConsoleExceptionListener.php","line":28,"class":"Kunstmaan\\AdminBundle\\EventListener\\ConsoleExceptionListener","function":"onConsoleException"}
Predictably, the same error as above is returned when trying to view search results on the frontend.