Skip to content

Commit ec0590c

Browse files
committed
fix: don't sync settings on dev/build
1 parent a3c286a commit ec0590c

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

src/Extensions/AlgoliaObjectExtension.php

+1-23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Wilr\Silverstripe\Algolia\Jobs\AlgoliaIndexItemJob;
2020
use Wilr\SilverStripe\Algolia\Service\AlgoliaIndexer;
2121
use Wilr\SilverStripe\Algolia\Service\AlgoliaService;
22+
use Wilr\SilverStripe\Algolia\Tasks\AlgoliaConfigure;
2223

2324
class AlgoliaObjectExtension extends DataExtension
2425
{
@@ -87,29 +88,6 @@ public function updateSettingsFields(FieldList $fields)
8788
}
8889
}
8990

90-
/**
91-
* On dev/build ensure that the indexer settings are up to date.
92-
*/
93-
public function requireDefaultRecords()
94-
{
95-
if ($this->ranSync) {
96-
return false;
97-
}
98-
99-
$this->ranSync = true;
100-
$algolia = Injector::inst()->create(AlgoliaService::class);
101-
102-
if (!$this->indexEnabled()) {
103-
return;
104-
}
105-
106-
try {
107-
$algolia->syncSettings();
108-
} catch (Throwable $e) {
109-
DB::alteration_message($e->getMessage(), 'error');
110-
}
111-
}
112-
11391
/**
11492
* Returns whether this object should be indexed into Algolia.
11593
*/

src/Tasks/AlgoliaConfigure.php

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public function run($request)
2424
{
2525
$service = Injector::inst()->get(AlgoliaService::class);
2626

27+
if (!$this->isEnabled()) {
28+
echo 'This task is disabled.' . PHP_EOL;
29+
return;
30+
}
31+
2732
try {
2833
if ($service->syncSettings()) {
2934
echo 'Success.' . PHP_EOL;

0 commit comments

Comments
 (0)