Remove enabling or disabling Redis via Web UI

This commit is contained in:
Pig Fang 2019-12-29 15:51:43 +08:00
parent 4689010466
commit a18f068387
8 changed files with 4 additions and 71 deletions

View File

@ -17,7 +17,6 @@ use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Str;
use Notification;
use Option;
@ -363,24 +362,6 @@ class AdminController extends Controller
})
->handle();
$redis = Option::form('redis', 'Redis', function ($form) {
$form->checkbox('enable_redis')->label()->description();
});
if (option('enable_redis')) {
try {
Redis::ping();
$redis->addAlert(trans('options.redis.connect.success'), 'success');
} catch (\Exception $e) {
$redis->addAlert(
trans('options.redis.connect.failed', ['msg' => $e->getMessage()]),
'danger'
);
}
}
$redis->handle();
$cache = Option::form('cache', OptionForm::AUTO_DETECT, function ($form) {
$form->checkbox('enable_avatar_cache')->label();
$form->checkbox('enable_preview_cache')->label();
@ -403,8 +384,7 @@ class AdminController extends Controller
}
$cache->handle();
return view('admin.resource')
->with('forms', compact('resources', 'redis', 'cache'));
return view('admin.resource')->with('forms', compact('resources', 'cache'));
}
public function status(

View File

@ -4,16 +4,10 @@ namespace App\Providers;
use App\Services;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('cipher', 'App\Services\Cipher\\'.config('secure.cipher'));
@ -25,30 +19,13 @@ class AppServiceProvider extends ServiceProvider
});
}
/**
* Bootstrap any application services.
*
* @codeCoverageIgnore
*/
public function boot(Request $request)
{
// Control the URL generated by url() function
$this->configureUrlGenerator($request);
try {
if (option('enable_redis') && Redis::ping()) {
config([
'cache.default' => 'redis',
'session.driver' => 'redis',
'queue.default' => 'redis',
]);
}
} catch (\Exception $e) {
}
}
/**
* Configure the \Illuminate\Routing\UrlGenerator.
* Control the URL generated by url() function.
*
* @codeCoverageIgnore
*/

View File

@ -38,7 +38,6 @@ return [
'copyright_prefer' => '0',
'score_per_closet_item' => '0',
'favicon_url' => 'app/favicon.ico',
'enable_redis' => 'false',
'score_award_per_texture' => '0',
'take_back_scores_after_deletion' => 'true',
'score_award_per_like' => '0',

View File

@ -194,15 +194,6 @@ resources:
all the files of that directory will be loaded as CDN.<br>
<b>How to verify?</b> Verify if <code>{Your CDN URL}/app/manifest.json</code> can be accessed.
redis:
enable_redis:
title: Enable
label: Enable Redis
description: Redis will be used to store cache, session and etc.
connect:
success: Connected to Redis server successfully.
failed: 'Failed to connect Redis server. Error: :msg'
cache:
title: Cache Configuration
clear: Clear Cache

View File

@ -55,6 +55,7 @@
- Removed restriction of texture name and nickname.
- Removed settings of "Method of Retrieving IP".
- Removed "3rd-party comment", and please install separated plugin if you need it.
- Removed enabling or disabling Redis via Web UI.
## Internal Changes

View File

@ -55,6 +55,7 @@
- 移除对材质名和用户昵称的要求
- 移除「IP 获取方法」的设置
- 移除「第三方评论」功能,如有需要请安装独立插件
- 移除通过 UI 来开启或关闭 Redis 的功能
## 内部更改

View File

@ -14,7 +14,6 @@
<div class="row">
<div class="col-md-6">
{{ forms.resources.render()|raw }}
{{ forms.redis.render()|raw }}
</div>
<div class="col-md-6">
{{ forms.cache.render()|raw }}

View File

@ -5,7 +5,6 @@ namespace Tests;
use Cache;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Redis;
use Mockery;
class AdminFormsTest extends BrowserKitTestCase
@ -187,20 +186,6 @@ class AdminFormsTest extends BrowserKitTestCase
->press('submit_resources');
$this->visit('/')->dontSee('url/app/app.js');
$this->visit('/admin/resource')
->check('enable_redis')
->press('submit_redis');
$this->assertTrue(option('enable_redis'));
Redis::shouldReceive('ping')->once()->andReturn(true);
$this->visit('/admin/resource')->see(trans('options.redis.connect.success'));
Redis::shouldReceive('ping')->once()->andThrow(new \Exception('fake'));
$this->visit('/admin/resource')
->see(trans('options.redis.connect.failed', ['msg' => 'fake']));
option(['enable_redis' => false]);
$this->visit('/admin/resource')
->see(trans('options.cache.driver', ['driver' => config('cache.default')]))
->check('enable_avatar_cache')