silverstripe / silverstripe-search-service

A service-agnostic search module for Silverstripe CMS
BSD 3-Clause "New" or "Revised" License
5 stars 18 forks source link

FIX ensure the ClearIndexJob doesn't break during initialisation #54

Closed scott1702 closed 3 years ago

scott1702 commented 3 years ago

QueuedJobs requires default values to be set in __construct which causes this job to be stuck in "Initialising" https://github.com/symbiote/silverstripe-queuedjobs/blob/89a057ce2c7e2f9560b8eea6d1974f423f45dc8b/docs/en/defining-jobs.md#api-overview

andrewandante commented 3 years ago

Huh, I think I've been burnt by this in other projects 😅

Does this prevent the job being created initially, but will run in the queue? Or does it "fail" if you don't pass in $indexName so you are forced to pass it in?

madmatt commented 3 years ago

I can confirm this works as expected. The issue was that when queuedjobs instantiates the job internally it doesn't pass any arguments. However, the job descriptor which is actually run still has all the details (e.g. the index name), so data gets cleared from the correct index.

madmatt commented 3 years ago

I'm happy merging this despite codecov packing a sad, there's no point testing the if(!$indexName) line