mirror of
https://github.com/flarum/core.git
synced 2025-08-05 07:57:46 +02:00
Fix onOneServer, withoutOverlapping console scheduling options
Flarum doesn't fully use Laravel's cache system, but rather creates and binds a single cache store. See \Flarum\Foundation\InstalledSite::registerCache Since certain config options (e.g. withoutOverlapping, onOneServer) need the cache, we must override the cache factory we give to the scheduling mutexes so it returns our single custom cache.
This commit is contained in:
31
framework/core/src/Console/Cache/Factory.php
Normal file
31
framework/core/src/Console/Cache/Factory.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flarum\Console\Cache;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Cache\Factory as FactoryContract;
|
||||||
|
use Illuminate\Contracts\Cache\Repository;
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
|
||||||
|
class Factory implements FactoryContract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Container
|
||||||
|
*/
|
||||||
|
private $container;
|
||||||
|
|
||||||
|
public function __construct(Container $container)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a cache store instance by name.
|
||||||
|
*
|
||||||
|
* @param string|null $name
|
||||||
|
* @return Repository
|
||||||
|
*/
|
||||||
|
public function store($name = null)
|
||||||
|
{
|
||||||
|
return $this->container['cache.store'];
|
||||||
|
}
|
||||||
|
}
|
@@ -9,15 +9,20 @@
|
|||||||
|
|
||||||
namespace Flarum\Console;
|
namespace Flarum\Console;
|
||||||
|
|
||||||
|
use Flarum\Console\Cache\Factory;
|
||||||
use Flarum\Database\Console\MigrateCommand;
|
use Flarum\Database\Console\MigrateCommand;
|
||||||
use Flarum\Database\Console\ResetCommand;
|
use Flarum\Database\Console\ResetCommand;
|
||||||
use Flarum\Foundation\AbstractServiceProvider;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
use Flarum\Foundation\Console\AssetsPublishCommand;
|
use Flarum\Foundation\Console\AssetsPublishCommand;
|
||||||
use Flarum\Foundation\Console\CacheClearCommand;
|
use Flarum\Foundation\Console\CacheClearCommand;
|
||||||
use Flarum\Foundation\Console\InfoCommand;
|
use Flarum\Foundation\Console\InfoCommand;
|
||||||
|
use Illuminate\Console\Scheduling\CacheEventMutex;
|
||||||
|
use Illuminate\Console\Scheduling\CacheSchedulingMutex;
|
||||||
|
use Illuminate\Console\Scheduling\EventMutex;
|
||||||
use Illuminate\Console\Scheduling\Schedule as LaravelSchedule;
|
use Illuminate\Console\Scheduling\Schedule as LaravelSchedule;
|
||||||
use Illuminate\Console\Scheduling\ScheduleListCommand;
|
use Illuminate\Console\Scheduling\ScheduleListCommand;
|
||||||
use Illuminate\Console\Scheduling\ScheduleRunCommand;
|
use Illuminate\Console\Scheduling\ScheduleRunCommand;
|
||||||
|
use Illuminate\Console\Scheduling\SchedulingMutex;
|
||||||
use Illuminate\Contracts\Container\Container;
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
|
||||||
class ConsoleServiceProvider extends AbstractServiceProvider
|
class ConsoleServiceProvider extends AbstractServiceProvider
|
||||||
@@ -33,6 +38,19 @@ class ConsoleServiceProvider extends AbstractServiceProvider
|
|||||||
define('ARTISAN_BINARY', 'flarum');
|
define('ARTISAN_BINARY', 'flarum');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flarum doesn't fully use Laravel's cache system, but rather
|
||||||
|
// creates and binds a single cache store.
|
||||||
|
// See \Flarum\Foundation\InstalledSite::registerCache
|
||||||
|
// Since certain config options (e.g. withoutOverlapping, onOneServer)
|
||||||
|
// need the cache, we must override the cache factory we give to the scheduling
|
||||||
|
// mutexes so it returns our single custom cache.
|
||||||
|
$this->container->bind(EventMutex::class, function ($container) {
|
||||||
|
return new CacheEventMutex($container->make(Factory::class));
|
||||||
|
});
|
||||||
|
$this->container->bind(SchedulingMutex::class, function ($container) {
|
||||||
|
return new CacheSchedulingMutex($container->make(Factory::class));
|
||||||
|
});
|
||||||
|
|
||||||
$this->container->singleton(LaravelSchedule::class, function (Container $container) {
|
$this->container->singleton(LaravelSchedule::class, function (Container $container) {
|
||||||
return $container->make(Schedule::class);
|
return $container->make(Schedule::class);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user