scout/settings/update fails if an index doesn't have indexSettings
If you run scout/settings/update and every one of your indices doesn't call indexSettings, you'll get an error:
Exception 'TypeError' with message 'Argument 1 passed to rias\scout\engines\AlgoliaEngine::updateSettings() must be an instance of rias\scout\IndexSettings, null given, called in /app/vendor/composer/rias/craft-scout/src/console/controllers/scout/SettingsController.php on line 22'
in /app/vendor/composer/rias/craft-scout/src/engines/AlgoliaEngine.php:85
Stack trace:
#0 /app/vendor/composer/rias/craft-scout/src/console/controllers/scout/SettingsController.php(22): rias\scout\engines\AlgoliaEngine->updateSettings(NULL)
#1 /app/vendor/composer/tightenco/collect/src/Collect/Support/Collection.php(475): rias\scout\console\controllers\scout\SettingsController->rias\scout\console\controllers\scout\{closure}(Object(rias\scout\engines\AlgoliaEngine), 1)
#2 /app/vendor/composer/rias/craft-scout/src/console/controllers/scout/SettingsController.php(24): Tightenco\Collect\Support\Collection->each(Object(Closure))
#3 [internal function]: rias\scout\console\controllers\scout\SettingsController->actionUpdate('')
#4 /app/vendor/composer/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#5 /app/vendor/composer/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#6 /app/vendor/composer/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('update', Array)
#7 /app/vendor/composer/craftcms/cms/src/console/Controller.php(199): yii\console\Controller->runAction('update', Array)
#8 /app/vendor/composer/yiisoft/yii2/base/Module.php(528): craft\console\Controller->runAction('update', Array)
#9 /app/vendor/composer/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('scout/settings/...', Array)
#10 /app/vendor/composer/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('scout/settings/...', Array)
#11 /app/vendor/composer/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('scout/settings/...', Array)
#12 /app/vendor/composer/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#13 /app/bin/craft(7): yii\base\Application->run()
#14 {main}
Seems like I forgot to add a test for this case ;) pretty straightforward fix to just filter the indices
Hi there. Is there a workaround for this? Our use case is that we do not want to overwrite any settings that have been set within the Algolia admin site, so we wouldn't be specifying any index settings within our Scout config file.
@chadwells Are you also running scout/settings/update ? That command is used to push settings from the scout config to Algolia so if don't want to do that I don't think you need this command.
D'oh! Yep that completely makes sense. 😵 Thanks!