mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-07 08:14:42 +03:00
Create getter for update checker inside the cron worker
This commit is contained in:
parent
5397f7014a
commit
fbe53e3b29
@ -66,9 +66,10 @@ class CronWorker
|
||||
public function __construct(PoolInterface $cache, UpdateChecker $update_checker = null)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->updateChecker = is_null($update_checker)
|
||||
? new UpdateChecker()
|
||||
: $update_checker;
|
||||
|
||||
if (!is_null($update_checker)) {
|
||||
$this->updateChecker = $update_checker;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,10 +100,11 @@ class CronWorker
|
||||
|
||||
if (Settings::get('autocheckupdates') == '1') {
|
||||
// Run the update checker
|
||||
if (!$this->updateChecker->run()) {
|
||||
$update_checker = $this->getUpdateChecker();
|
||||
if (!$update_checker->run()) {
|
||||
$this->errors = array_merge(
|
||||
$this->errors,
|
||||
$this->updateChecker->getErrors()
|
||||
$update_checker->getErrors()
|
||||
);
|
||||
|
||||
return false;
|
||||
@ -137,4 +139,20 @@ class CronWorker
|
||||
{
|
||||
return $this->log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrives an instance of Update Checker attached to the worker.
|
||||
*
|
||||
* If there was no attached checker it creates a new one.
|
||||
*
|
||||
* @return UpdateChecker
|
||||
*/
|
||||
protected function getUpdateChecker()
|
||||
{
|
||||
if (is_null($this->updateChecker)) {
|
||||
$this->updateChecker = new UpdateChecker();
|
||||
}
|
||||
|
||||
return $this->updateChecker;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user