Skip to content

Commit ab66be3

Browse files
committed
コアのアップデート時、開発版かどうかを判定し、開発版の場合は手動アップデートの手順を表示するようにした
1 parent 8de42ee commit ab66be3

File tree

8 files changed

+44
-6
lines changed

8 files changed

+44
-6
lines changed

plugins/baser-core/src/Controller/Admin/PluginsController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ public function update(PluginsAdminServiceInterface $service, $name = '')
118118
if (!$this->viewBuilder()->getVar('isWritableComposerLock')) {
119119
$message[] = __d('baser_core', ROOT . DS . 'composer.lock に書き込み権限を設定してください。');
120120
}
121-
if($message) {
121+
if ($this->viewBuilder()->getVar('isDevelopmentVersion')) {
122+
$message[] = __d('baser_core', "現在開発版を利用しているため、アップデートは利用できません。\n(plugins フォルダに、baserCMSコアが存在する場合、開発版として認識されます。)");
123+
}
124+
if ($message) {
122125
$this->BcMessage->setError(implode("\n", $message));
123126
}
124127
}

plugins/baser-core/src/Service/Admin/PluginsAdminService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ public function getViewVarsForUpdate(EntityInterface $entity): array
9191
$isWritableVendor = is_writable(ROOT . DS . 'vendor');
9292
$isWritableComposerJson = is_writable(ROOT . DS . 'composer.json');
9393
$isWritableComposerLock = is_writable(ROOT . DS . 'composer.lock');
94+
$isDevelopmentVersion = BcUtil::isDevelopmentVersion();
9495
$requireUpdate = $this->isRequireUpdate(
9596
$programVersion,
9697
$dbVersion,
9798
$availableVersion
9899
);
99100
if($entity->name === 'BaserCore') {
100-
$isUpdatable = ($requireUpdate && $isWritableVendor && $isWritableComposerJson && $isWritableComposerLock);
101+
$isUpdatable = (!$isDevelopmentVersion && $requireUpdate && $isWritableVendor && $isWritableComposerJson && $isWritableComposerLock);
101102
} else {
102103
$isUpdatable = $requireUpdate;
103104
}
@@ -117,7 +118,8 @@ public function getViewVarsForUpdate(EntityInterface $entity): array
117118
'isWritableVendor' => $isWritableVendor,
118119
'isWritableComposerJson' => $isWritableComposerJson,
119120
'isWritableComposerLock' => $isWritableComposerLock,
120-
'isUpdatable' => $isUpdatable
121+
'isUpdatable' => $isUpdatable,
122+
'isDevelopmentVersion' => $isDevelopmentVersion
121123
];
122124
}
123125

plugins/baser-core/src/Utility/BcUtil.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,4 +2314,13 @@ public static function is51()
23142314
return false;
23152315
}
23162316

2317+
/**
2318+
* 開発版かどうかを判定
2319+
* @return bool
2320+
*/
2321+
public static function isDevelopmentVersion(): bool
2322+
{
2323+
return is_dir(ROOT . DS . 'plugins' . DS . 'baser-core');
2324+
}
2325+
23172326
}

plugins/baser-core/tests/TestCase/Utility/BcUtilTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,4 +1709,14 @@ public function testAddSessionId()
17091709
$this->loginAdmin($this->getRequest('/baser/admin'));
17101710
$this->assertEquals('/', BcUtil::addSessionId('/'));
17111711
}
1712+
1713+
/**
1714+
* test isDevelopmentVersion
1715+
*/
1716+
public function testIsDevelopmentVersion()
1717+
{
1718+
// 開発環境(baser-coreディレクトリが存在する)であることを確認
1719+
$this->assertTrue(BcUtil::isDevelopmentVersion());
1720+
}
1721+
17121722
}

plugins/bc-admin-third/src/js/admin/plugins/update.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ const updateForm = {
7474
if ($inputPhp.val() !== ''){
7575
if(updateForm.isUpdatable) {
7676
$btnUpdate.removeAttr('disabled');
77+
$btnDownload.removeAttr('disabled');
7778
} else {
7879
$btnUpdate.attr('disabled', 'disabled');
80+
$btnDownload.attr('disabled', 'disabled');
7981
}
80-
$btnDownload.removeAttr('disabled');
8182
} else {
8283
$btnUpdate.attr('disabled', 'disabled');
8384
$btnDownload.attr('disabled', 'disabled');

plugins/bc-admin-third/templates/Admin/Plugins/update.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* @var bool $isCore
2020
* @var bool $isUpdatable
2121
* @var bool $coreDownloaded
22+
* @var bool $isDevelopmentVersion
2223
*/
2324
$this->BcAdmin->setTitle(__d('baser_core', 'baserCMSコア|アップデート'));
2425
$this->BcBaser->i18nScript([
@@ -35,6 +36,18 @@
3536

3637

3738
<div class="bca-plugin-update">
39+
<?php if ($isDevelopmentVersion): ?>
40+
<div class="bca-panel-box">
41+
<h2 class="bca-main__heading" data-bca-heading-size="lg">
42+
<?php echo __d('baser_core', '手動アップデート手順') ?>
43+
</h2>
44+
<ol>
45+
<li>plugins 内の、baserCMSコアのプラグイン群を手動で入れ替え</li>
46+
<li>BcUpdateSupporterプラグインで、アップデートスクリプトを実行</li>
47+
<li>BcUpdateSupporterプラグインで、データベースのバージョンを更新</li>
48+
</ol>
49+
</div>
50+
<?php endif ?>
3851

3952
<?php $this->BcBaser->element('Plugins/update_now_status') ?>
4053

plugins/bc-admin-third/webroot/js/admin/plugins/update.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/bc-admin-third/webroot/js/admin/plugins/update.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)