Skip to content

Commit

Permalink
Fix clear cache, update storage paths
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Feb 7, 2015
1 parent 0990487 commit 9a616b6
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 32 deletions.
13 changes: 7 additions & 6 deletions modules/backend/controllers/index/_warnings.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
$uploadsDir,
$uploadsDir.'/public',
$uploadsDir.'/protected',
'/app/storage',
'/app/storage/logs',
'/app/storage/cache',
'/app/storage/twig',
'/app/storage/meta',
'/app/storage/combiner',
'/storage',
'/storage/logs',
'/storage/framework',
'/storage/cms',
'/storage/cms/cache',
'/storage/cms/twig',
'/storage/cms/combiner',
];
$requiredExtensions = [
'GD' => extension_loaded('gd'),
Expand Down
2 changes: 1 addition & 1 deletion modules/cms/classes/CodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function validate($php)
protected function getFilePath()
{
$hash = abs(crc32($this->filePath));
$result = storage_path().'/cache/';
$result = storage_path().'/cms/cache/';
$result .= substr($hash, 0, 2).'/';
$result .= substr($hash, 2, 2).'/';
$result .= basename($this->filePath).'.php';
Expand Down
2 changes: 1 addition & 1 deletion modules/cms/classes/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ protected function initTwigEnvironment()
'debug' => $isDebugMode,
];
if (!Config::get('cms.twigNoCache')) {
$options['cache'] = storage_path().'/twig';
$options['cache'] = storage_path().'/cms/twig';
}

$this->twig = new Twig_Environment($this->loader, $options);
Expand Down
23 changes: 9 additions & 14 deletions modules/system/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public function register()
*/
parent::register('system');

/*
* Register core providers
*/
// App::register('October\Rain\Translation\TranslationServiceProvider');

/*
* Define path constants
*/
Expand Down Expand Up @@ -121,7 +116,7 @@ public function register()
/*
* Register basic Twig
*/
App::bindShared('twig', function ($app) {
App::singleton('twig', function ($app) {
$twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]);
$twig->addExtension(new TwigExtension);
return $twig;
Expand All @@ -137,7 +132,7 @@ public function register()
/*
* Register Twig that will parse strings
*/
App::bindShared('twig.string', function ($app) {
App::singleton('twig.string', function ($app) {
$twig = $app['twig'];
$twig->setLoader(new Twig_Loader_String);
return $twig;
Expand Down Expand Up @@ -321,6 +316,13 @@ public function register()
]);
});

/*
* Override clear cache command
*/
App::singleton('command.cache.clear', function ($app) {
return new \System\Console\CacheClear($app['cache'], $app['files']);
});

/*
* Register console commands
*/
Expand All @@ -332,13 +334,6 @@ public function register()
$this->registerConsoleCommand('plugin.remove', 'System\Console\PluginRemove');
$this->registerConsoleCommand('plugin.refresh', 'System\Console\PluginRefresh');

/*
* Override clear cache command
*/
App::bindShared('command.cache.clear', function ($app) {
return new \System\Console\CacheClear($app['cache'], $app['files']);
});

/*
* Register the sidebar for the System main menu
*/
Expand Down
4 changes: 2 additions & 2 deletions modules/system/classes/CombineAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function getContents($cacheId)
}

$this->path = $cacheInfo['path'];
$this->storagePath = storage_path().'/combiner/cms';
$this->storagePath = storage_path().'/cms/combiner';

$combiner = $this->prepareCombiner($cacheInfo['files']);
$contents = $combiner->dump();
Expand Down Expand Up @@ -278,7 +278,7 @@ protected function prepareRequest(array $assets, $path = null)
}

$this->path = public_path().$path;
$this->storagePath = storage_path().'/combiner/cms';
$this->storagePath = storage_path().'/cms/combiner';

list($assets, $extension) = $this->prepareAssets($assets);

Expand Down
10 changes: 5 additions & 5 deletions modules/system/classes/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PluginManager
/**
* @var string Path to the disarm file.
*/
protected $metaPath;
protected $metaFile;

/**
* @var array Collection of disabled plugins
Expand All @@ -67,7 +67,7 @@ class PluginManager
protected function init()
{
$this->app = App::make('app');
$this->metaPath = Config::get('app.manifest');
$this->metaFile = storage_path() . '/cms/disabled.json';
$this->loadDisabled();
$this->loadPlugins();
$this->loadDependencies();
Expand Down Expand Up @@ -369,7 +369,7 @@ public function normalizeIdentifier($identifier)

public function clearDisabledCache()
{
File::delete($this->metaPath.'/disabled.json');
File::delete($this->metaFile);
$this->disabledPlugins = [];
}

Expand All @@ -378,7 +378,7 @@ public function clearDisabledCache()
*/
protected function loadDisabled()
{
$path = $this->metaPath.'/disabled.json';
$path = $this->metaFile;

if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
foreach ($configDisabled as $disabled) {
Expand Down Expand Up @@ -413,7 +413,7 @@ public function isDisabled($id)
*/
protected function writeDisabled()
{
$path = $this->metaPath.'/disabled.json';
$path = $this->metaFile;
File::put($path, json_encode($this->disabledPlugins));
}

Expand Down
39 changes: 36 additions & 3 deletions modules/system/console/CacheClear.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,39 @@
use Config;
use Illuminate\Cache\Console\ClearCommand;
use Symfony\Component\Console\Output\NullOutput;
use Illuminate\Cache\CacheManager;
use Illuminate\Filesystem\Filesystem;

class CacheClear extends ClearCommand
{
/**
* The file system instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;

/**
* Create a new cache clear command instance.
*
* @param \Illuminate\Cache\CacheManager $cache
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
*/
public function __construct(CacheManager $cache, Filesystem $files)
{
parent::__construct($cache);

$this->files = $files;
}

/**
* Execute the console command.
*/
public function fire()
{
$storagePath = $this->laravel->storagePath();

/*
* Allow this command to be executed internally
*/
Expand All @@ -22,16 +47,24 @@ public function fire()
/*
* Combiner
*/
foreach ($this->files->directories(storage_path().'/combiner') as $directory) {
foreach ($this->files->directories($storagePath.'/cms/combiner') as $directory) {
$this->files->deleteDirectory($directory);
}
$this->info('Combiner cache cleared!');

/*
* Combiner
*/
foreach ($this->files->directories($storagePath.'/cms/cache') as $directory) {
$this->files->deleteDirectory($directory);
}
$this->info('CMS cache cleared!');

/*
* Twig
*/
if (!Config::get('cms.twigNoCache')) {
foreach ($this->files->directories(storage_path().'/twig') as $directory) {
foreach ($this->files->directories($storagePath.'/cms/twig') as $directory) {
$this->files->deleteDirectory($directory);
}
$this->info('Twig cache cleared!');
Expand All @@ -40,7 +73,7 @@ public function fire()
/*
* Meta
*/
$this->files->delete($this->laravel['config']['app.manifest'].'/disabled.json');
$this->files->delete($storagePath.'/cms/disabled.json');

parent::fire();
}
Expand Down
6 changes: 6 additions & 0 deletions storage/cms/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config.php
routes.php
compiled.php
services.json
events.scanned.php
routes.scanned.php
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9a616b6

Please sign in to comment.