Check PHP version before updating
This commit is contained in:
parent
4c2c74dafb
commit
a36c31e5bd
|
|
@ -104,7 +104,7 @@ class MarketController extends Controller
|
||||||
protected function getAllAvailablePlugins()
|
protected function getAllAvailablePlugins()
|
||||||
{
|
{
|
||||||
$registryVersion = 1;
|
$registryVersion = 1;
|
||||||
if (app()->environment('testing') || ! $this->registryCache) {
|
if (app()->runningUnitTests() || ! $this->registryCache) {
|
||||||
$registries = collect(explode(',', config('plugins.registry')));
|
$registries = collect(explode(',', config('plugins.registry')));
|
||||||
$this->registryCache = $registries->map(function ($registry) use ($registryVersion) {
|
$this->registryCache = $registries->map(function ($registry) use ($registryVersion) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@ class UpdateController extends Controller
|
||||||
|
|
||||||
protected function getUpdateInfo()
|
protected function getUpdateInfo()
|
||||||
{
|
{
|
||||||
$acceptableSpec = 1;
|
$acceptableSpec = 2;
|
||||||
if (! $this->info) {
|
if (app()->runningUnitTests() || ! $this->info) {
|
||||||
try {
|
try {
|
||||||
$json = $this->guzzle->request(
|
$json = $this->guzzle->request(
|
||||||
'GET',
|
'GET',
|
||||||
|
|
@ -79,7 +79,7 @@ class UpdateController extends Controller
|
||||||
if (Arr::get($info, 'spec') == $acceptableSpec) {
|
if (Arr::get($info, 'spec') == $acceptableSpec) {
|
||||||
$this->info = $info;
|
$this->info = $info;
|
||||||
} else {
|
} else {
|
||||||
$this->error = trans('admin.update.spec');
|
$this->error = trans('admin.update.errors.spec');
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->error = $e->getMessage();
|
$this->error = $e->getMessage();
|
||||||
|
|
@ -93,6 +93,12 @@ class UpdateController extends Controller
|
||||||
{
|
{
|
||||||
$this->getUpdateInfo();
|
$this->getUpdateInfo();
|
||||||
|
|
||||||
|
$php = Arr::get($this->info, 'php');
|
||||||
|
if (Comparator::lessThan(PHP_VERSION, $php)) {
|
||||||
|
$this->error = trans('admin.update.errors.php', ['version' => $php]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return Comparator::greaterThan(Arr::get($this->info, 'latest'), $this->currentVersion);
|
return Comparator::greaterThan(Arr::get($this->info, 'latest'), $this->currentVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ return [
|
||||||
'update_source' => env(
|
'update_source' => env(
|
||||||
'UPDATE_SOURCE',
|
'UPDATE_SOURCE',
|
||||||
'https://dev.azure.com/blessing-skin/51010f6d-9f99-40f1-a262-0a67f788df32/_apis/git/'.
|
'https://dev.azure.com/blessing-skin/51010f6d-9f99-40f1-a262-0a67f788df32/_apis/git/'.
|
||||||
'repositories/a9ff8df7-6dc3-4ff8-bb22-4871d3a43936/Items?path=%2Fupdate.json'
|
'repositories/a9ff8df7-6dc3-4ff8-bb22-4871d3a43936/Items?path=%2Fupdate_2.json'
|
||||||
),
|
),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,6 @@ update:
|
||||||
check-github: <a href=":url" target="_blank" class="el-button pull-right">Check GitHub Releases</a>
|
check-github: <a href=":url" target="_blank" class="el-button pull-right">Check GitHub Releases</a>
|
||||||
button: Update Now
|
button: Update Now
|
||||||
|
|
||||||
spec: Current update source is not supported.
|
|
||||||
|
|
||||||
cautions:
|
cautions:
|
||||||
title: Cautions
|
title: Cautions
|
||||||
text: |
|
text: |
|
||||||
|
|
@ -141,6 +139,8 @@ update:
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
connection: "Unable to access to current update source. Details: :error"
|
connection: "Unable to access to current update source. Details: :error"
|
||||||
|
spec: Current update source is not supported.
|
||||||
|
php: Your PHP version is too low to update. Requires :version or later.
|
||||||
|
|
||||||
download:
|
download:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,6 @@ update:
|
||||||
check-github: <a href=":url" target="_blank" class="el-button pull-right">查看 GitHub Releases</a>
|
check-github: <a href=":url" target="_blank" class="el-button pull-right">查看 GitHub Releases</a>
|
||||||
button: 马上升级
|
button: 马上升级
|
||||||
|
|
||||||
spec: 不支持当前的更新源。
|
|
||||||
|
|
||||||
cautions:
|
cautions:
|
||||||
title: 注意事项
|
title: 注意事项
|
||||||
text: |
|
text: |
|
||||||
|
|
@ -146,6 +144,8 @@ update:
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
connection: 无法访问当前更新源。详细信息::error
|
connection: 无法访问当前更新源。详细信息::error
|
||||||
|
spec: 不支持当前的更新源。
|
||||||
|
php: PHP 版本过低,至少需要 :version。
|
||||||
|
|
||||||
download:
|
download:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
- Optimized panel of changing theme color.
|
- Optimized panel of changing theme color.
|
||||||
- Tweaked some links at closet page.
|
- Tweaked some links at closet page.
|
||||||
- Limited that only super administrators can visit update pages.
|
- Limited that only super administrators can visit update pages.
|
||||||
|
- Update source specification version has been changed to `2`.
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
- 优化「更改配色」的面板
|
- 优化「更改配色」的面板
|
||||||
- 调整衣柜页面上的某些链接
|
- 调整衣柜页面上的某些链接
|
||||||
- 限制仅超级管理员才能访问升级页面
|
- 限制仅超级管理员才能访问升级页面
|
||||||
|
- 更新源信息 spec 版本更改为 `2`
|
||||||
|
|
||||||
## 修复
|
## 修复
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ zip -9 -r blessing-skin-server-$RELEASE_TAG.zip \
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cd dist
|
cd dist
|
||||||
cp ../blessing-skin-server-$RELEASE_TAG.zip blessing-skin-server-$RELEASE_TAG.zip
|
cp ../blessing-skin-server-$RELEASE_TAG.zip blessing-skin-server-$RELEASE_TAG.zip
|
||||||
echo "{\"spec\":1,\"latest\":\"$RELEASE_TAG\",\"url\":\"https://dev.azure.com/blessing-skin/51010f6d-9f99-40f1-a262-0a67f788df32/_apis/git/repositories/a9ff8df7-6dc3-4ff8-bb22-4871d3a43936/Items?path=%2Fblessing-skin-server-$RELEASE_TAG.zip\"}" > update.json
|
echo "{\"spec\":2,\"php\":\"7.1.8\",\"latest\":\"$RELEASE_TAG\",\"url\":\"https://dev.azure.com/blessing-skin/51010f6d-9f99-40f1-a262-0a67f788df32/_apis/git/repositories/a9ff8df7-6dc3-4ff8-bb22-4871d3a43936/Items?path=%2Fblessing-skin-server-$RELEASE_TAG.zip\"}" > update_2.json
|
||||||
git init
|
git init
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Publish"
|
git commit -m "Publish"
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,17 @@ class UpdateControllerTest extends TestCase
|
||||||
|
|
||||||
// Missing `spec` field
|
// Missing `spec` field
|
||||||
$this->appendToGuzzleQueue([
|
$this->appendToGuzzleQueue([
|
||||||
new Response(200, [], json_encode(['latest' => '8.9.3', 'url' => ''])),
|
new Response(200, [], $this->mockFakeUpdateInfo('8.9.3', ['spec' => 0])),
|
||||||
|
// Weird. Don't remove the following line, or the tests will fail.
|
||||||
|
new Response(200, [], $this->mockFakeUpdateInfo('8.9.3', ['php' => '100.0.0'])),
|
||||||
]);
|
]);
|
||||||
$this->get('/admin/update')->assertSee(trans('admin.update.spec'));
|
$this->get('/admin/update')->assertSee(trans('admin.update.errors.spec'));
|
||||||
|
|
||||||
|
// Low PHP version
|
||||||
|
$this->appendToGuzzleQueue([
|
||||||
|
new Response(200, [], $this->mockFakeUpdateInfo('8.9.3', ['php' => '100.0.0'])),
|
||||||
|
]);
|
||||||
|
$this->get('/admin/update')->assertSee(trans('admin.update.errors.php', ['version' => '100.0.0']));
|
||||||
|
|
||||||
// New version available
|
// New version available
|
||||||
$this->appendToGuzzleQueue([
|
$this->appendToGuzzleQueue([
|
||||||
|
|
@ -91,12 +99,13 @@ class UpdateControllerTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function mockFakeUpdateInfo($version)
|
protected function mockFakeUpdateInfo(string $version, $extra = [])
|
||||||
{
|
{
|
||||||
return json_encode([
|
return json_encode(array_merge([
|
||||||
'spec' => 1,
|
'spec' => 2,
|
||||||
|
'php' => '7.1.8',
|
||||||
'latest' => $version,
|
'latest' => $version,
|
||||||
'url' => "https://whatever.test/$version/update.zip",
|
'url' => "https://whatever.test/$version/update.zip",
|
||||||
]);
|
], $extra));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user