Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Error when using AlgoliaObjectExtension on record without stages #59

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Extensions/AlgoliaObjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SilverStripe\ORM\DB;
use Ramsey\Uuid\Uuid;
use SilverStripe\Core\Convert;
use SilverStripe\Versioned\Versioned;
use Symbiote\QueuedJobs\Services\QueuedJobService;
use Throwable;
use Wilr\Silverstripe\Algolia\Jobs\AlgoliaDeleteItemJob;
Expand Down Expand Up @@ -78,9 +79,9 @@ public function updateSettingsFields(FieldList $fields)
$fields->addFieldsToTab(
'Root.Search',
[
ReadonlyField::create('AlgoliaIndexed', _t(__CLASS__.'.LastIndexed', 'Last indexed in Algolia'))
->setDescription($this->owner->AlgoliaError),
ReadonlyField::create('AlgoliaUUID', _t(__CLASS__.'.UUID', 'Algolia UUID'))
ReadonlyField::create('AlgoliaIndexed', _t(__CLASS__.'.LastIndexed', 'Last indexed in Algolia'))
->setDescription($this->owner->AlgoliaError),
ReadonlyField::create('AlgoliaUUID', _t(__CLASS__.'.UUID', 'Algolia UUID'))
]
);
}
Expand Down Expand Up @@ -174,7 +175,7 @@ private function updateAlgoliaFields($fields)
$set = implode(', ', $sets);
DB::query(sprintf('UPDATE %s SET %s WHERE ID = %s', $table, $set, $this->owner->ID));

if ($this->owner->hasExtension('SilverStripe\Versioned\Versioned')) {
if ($this->owner->hasExtension(Versioned::class) && $this->owner->hasStages()) {
DB::query(
sprintf(
'UPDATE %s_Live SET %s WHERE ID = %s',
Expand Down