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

feat: backport fix for #266 to Craft 3 #288

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

qrazi
Copy link

@qrazi qrazi commented Dec 12, 2023

The issue described in #266 also affects Craft 3 version of this plugin. So this PR back-ports the fix as is.

What we usually do in our own custom modules when it comes to potentially off-loading to the queue, is to always run the job. But conditionally on the queue.

So, in this case we would have done:

$job = new IndexElement([
    'id' => $element->id,
    'siteId' => $element->site->id,
]);
$queue = Craft::$app->getQueue();
if (Scout::$plugin->getSettings()->queue) {
    $queue->push($job);
} else {
    $job->execute($queue);
}

This way both paths end up doing the same work. Now if Scout::$plugin->getSettings()->queue === false, the extra work that the Job does does not get executed.

I didn't think I should "pollute" this PR with that, but I could put this in a new PR if interested?

@janhenckens
Copy link
Member

Hey @qrazi, that's an interesting approach - I haven't seen that done before. Feel free to make a new PR for that if you'd like!

Meanwhile I'll merge this fix for Craft 3 as well.

@janhenckens janhenckens merged commit 43d2a65 into studioespresso:craft3 Dec 27, 2023
2 checks passed
@qrazi qrazi deleted the feat_backport_266_craft3 branch January 8, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants