Skip to content

Commit

Permalink
Merge branch '5.1.x' into password-reset-interval
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring authored Jul 15, 2024
2 parents a1324dc + c6b1c74 commit 3c825c5
Show file tree
Hide file tree
Showing 84 changed files with 725 additions and 582 deletions.
2 changes: 0 additions & 2 deletions config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export APP_DEFAULT_TIMEZONE="Asia/Tokyo"
export INSTALL_MODE="true"
export USE_DEBUG_KIT="false"
export SITE_URL="https://localhost/"
export SSL_URL="https://localhost/"
export ADMIN_SSL="true"
export ADMIN_PREFIX="admin"
export BASER_CORE_PREFIX="baser"
export SQL_LOG="false"
Expand Down
28 changes: 14 additions & 14 deletions plugins/baser-core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
"josegonzalez/dotenv": "^3.2",
"mobiledetect/mobiledetectlib": "^4.8.03",
"ext-json": "*",
"baserproject/bc-admin-third": "5.1.*",
"baserproject/bc-blog": "5.1.*",
"baserproject/bc-content-link": "5.1.*",
"baserproject/bc-custom-content": "5.1.*",
"baserproject/bc-editor-template": "5.1.*",
"baserproject/bc-favorite": "5.1.*",
"baserproject/bc-front": "5.1.*",
"baserproject/bc-installer": "5.1.*",
"baserproject/bc-mail": "5.1.*",
"baserproject/bc-search-index": "5.1.*",
"baserproject/bc-theme-config": "5.1.*",
"baserproject/bc-theme-file": "5.1.*",
"baserproject/bc-uploader": "5.1.*",
"baserproject/bc-widget-area": "5.1.*",
"baserproject/bc-admin-third": "5.1.x",
"baserproject/bc-blog": "5.1.x",
"baserproject/bc-content-link": "5.1.x",
"baserproject/bc-custom-content": "5.1.x",
"baserproject/bc-editor-template": "5.1.x",
"baserproject/bc-favorite": "5.1.x",
"baserproject/bc-front": "5.1.x",
"baserproject/bc-installer": "5.1.x",
"baserproject/bc-mail": "5.1.x",
"baserproject/bc-search-index": "5.1.x",
"baserproject/bc-theme-config": "5.1.x",
"baserproject/bc-theme-file": "5.1.x",
"baserproject/bc-uploader": "5.1.x",
"baserproject/bc-widget-area": "5.1.x",
"ext-mbstring": "*",
"ext-zip": "*",
"ext-gd": "*"
Expand Down
9 changes: 0 additions & 9 deletions plugins/baser-core/config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@
* サイトURL
*/
'siteUrl' => env('SITE_URL', 'https://localhost/'),
/**
* SSL URL
*/
'sslUrl' => env('SSL_URL', 'https://localhost/'),
/**
* CMS URL
* CMSのURLが別ドメインの場合に設定する
Expand Down Expand Up @@ -331,11 +327,6 @@
*/
'passwordRequestAllowTime' => 1440,

/**
* 管理画面のSSL
*/
'adminSsl' => filter_var(env('ADMIN_SSL', true), FILTER_VALIDATE_BOOLEAN),

/**
* エディタ
*/
Expand Down
13 changes: 6 additions & 7 deletions plugins/baser-core/config/update/5.1.0/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@

/**
* 5.1.0 アップデーター
*
* 書き込み権限チェック
*/
$notWritablePath = [];
if(!is_writable(ROOT . DS . 'src' . DS . 'View' . DS . 'AjaxView.php')) {
$notWritablePath[] = ROOT . DS . 'src' . DS . 'View' . DS . 'AjaxView.php';
}
$message = "baserCMS 5.1.0 へのアップデートの際、プラグインに問題がある場合、アップデート完了後に画面が表示できなくなる可能性があります。\n" .
"アップデート前に、コアプラグイン以外を一度無効化しておいてください。";
if($notWritablePath) {
return [
'updateMessage' => "アップデートを実行する前に次のファイルみ書き込み権限を与えてください<br>" . implode('<br>', $notWritablePath)
];
} else {
return [];
$message .= "\nアップデートを実行する前に次のファイルみ書き込み権限を与えてください<br>" . implode('<br>', $notWritablePath);
}
return [
'updateMessage' => $message
];
7 changes: 7 additions & 0 deletions plugins/baser-core/config/update/5.1.0/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/**
* 5.1.0 アップデーター
*/

use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\Utility\BcContainer;
use BaserCore\Utility\BcUpdateLog;

$updateDir = __DIR__;
Expand All @@ -21,3 +24,7 @@
} else {
BcUpdateLog::set(__d('baser_core', ROOT . DS . 'src' . DS . 'View' . DS . 'AjaxView.php に書き込み権限がありません。' . $updateDir . DS . 'src' . DS . 'View' . DS . 'AjaxView.php をコピーして手動で上書きしてください。'));
}

/** @var \BaserCore\Service\SiteConfigsService $siteConfigsService */
$siteConfigsService = BcContainer::get()->get(SiteConfigsServiceInterface::class);
$siteConfigsService->setValue('allow_simple_password', true);
8 changes: 0 additions & 8 deletions plugins/baser-core/src/BaserCorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,6 @@ public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
->add(new BcFrontMiddleware())
->add(new BcRedirectSubSiteMiddleware());

if (Configure::read('BcApp.adminSsl') && !BcUtil::isConsole() && BcUtil::isAdminSystem() && BcUtil::isInstalled()) {
$config = ['redirect' => false];
if(filter_var(env('TRUST_PROXY', false))) {
$config['trustedProxies'] = !empty($_SERVER['HTTP_X_FORWARDED_FOR'])? [$_SERVER['HTTP_X_FORWARDED_FOR']] : [];
}
$middlewareQueue->add(new HttpsEnforcerMiddleware($config));
}

// APIへのアクセスの場合、セッションによる認証以外は、CSRFを利用しない設定とする
$ref = new ReflectionClass($middlewareQueue);
$queue = $ref->getProperty('queue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected function _checkReferer(): bool
}

/**
* siteUrlや、sslUrlと現在のURLが違う場合には、そちらのURLにリダイレクトを行う
* siteUrlや、cmsUrlと現在のURLが違う場合には、そちらのURLにリダイレクトを行う
* setting.php にて、cmsUrlとして、cmsUrlを定義した場合にはそちらを優先する
* @return Response|void|null
* @checked
Expand All @@ -211,8 +211,6 @@ public function redirectIfIsNotSameSite()
{
if (Configure::read('BcEnv.cmsUrl')) {
$siteUrl = Configure::read('BcEnv.cmsUrl');
} elseif ($this->getRequest()->is('https')) {
$siteUrl = Configure::read('BcEnv.sslUrl');
} else {
$siteUrl = Configure::read('BcEnv.siteUrl');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ public function get_core_update(PluginsAdminServiceInterface $service)
$request->getData('php')?? 'php',
$request->getData('force'),
);
$this->BcMessage->setSuccess(__d('baser_core', '最新版のダウンロードが完了しました。アップデートを実行してください。'));
} catch (\Throwable $e) {
$this->BcMessage->setError($e->getMessage());
}
$this->BcMessage->setSuccess(__d('baser_core', '最新版のダウンロードが完了しました。アップデートを実行してください。'));
return $this->redirect(['action' => 'update']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ContentsController extends BcAdminApiController
* @param int $id
* @checked
* @noTodo
* @unitTest
*/
public function view(ContentsServiceInterface $service, int $id)
{
Expand Down Expand Up @@ -121,6 +122,7 @@ public function index(ContentsServiceInterface $service)
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function index_trash(ContentsServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PagesController extends BcAdminApiController
* @param PagesServiceInterface $service
* @checked
* @noTodo
* @unitTest
*/
public function index(PagesServiceInterface $service)
{
Expand Down
17 changes: 8 additions & 9 deletions plugins/baser-core/src/Model/Table/PagesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,19 @@ public function copy(
'id' => $page->id
]);
if ($event !== false) {
$page = $event->getResult() === true? $event->getData('data') : $event->getResult();
$page = $event->getResult() === true ? $event->getData('data') : $event->getResult();
unset($event);
}

unset($page->created, $page->modified);
$page->content = new Content([
'name' => $page->content->name,
'parent_id' => $newParentId,
'title' => $newTitle ?? $oldPage->content->title . '_copy',
'author_id' => $newAuthorId,
'site_id' => $newSiteId,
'description' => $page->content->description,
'eyecatch' => $page->content->eyecatch,
'layout_template' => $page->content->layout_tmplate?? ''
'name' => $page->content->name,
'parent_id' => $newParentId,
'title' => $newTitle ?? $oldPage->content->title . '_copy',
'author_id' => $newAuthorId,
'site_id' => $newSiteId,
'description' => $page->content->description,
'layout_template' => $page->content->layout_tmplate ?? ''
]);

if (!is_null($newSiteId) && $oldPage->content->site_id !== $newSiteId) {
Expand Down
14 changes: 0 additions & 14 deletions plugins/baser-core/src/Model/Table/SiteConfigsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public function validationDefault(Validator $validator): Validator
*/
public function validationKeyValue(Validator $validator): Validator
{
$validator->setProvider('siteConfig', 'BaserCore\Model\Validation\SiteConfigValidation');

$validator
->scalar('email')
->email('email', 255, __d('baser_core', '管理者メールアドレスの形式が不正です。'))
Expand All @@ -87,18 +85,6 @@ public function validationKeyValue(Validator $validator): Validator
->scalar('site_url')
->regex('site_url', '/^(http|https):/', __d('baser_core', 'WebサイトURLはURLの形式を入力してください。'))
->notEmptyString('site_url', __d('baser_core', 'WebサイトURLを入力してください。'));
$validator
->scalar('ssl_url')
->regex('ssl_url', '/^(http|https):/', __d('baser_core', 'WebサイトURLはURLの形式を入力してください。'))
->notEmptyString('ssl_url', __d('baser_core', 'WebサイトURLを入力してください。'));
$validator
->scalar('admin_ssl')
->add('admin_ssl', [
'adminSSlSslUrlExists' => [
'rule' => 'sslUrlExists',
'provider' => 'siteConfig',
'message' => __d('baser_core', '管理画面をSSLで利用するには、SSL用のWebサイトURLを入力してください。')
]]);
$validator
->allowEmptyString('password_reset_days')
->nonNegativeInteger('password_reset_days', __d('baser_core', 'パスワードの再設定日数は0以上の整数を入力してください。'));
Expand Down
7 changes: 3 additions & 4 deletions plugins/baser-core/src/Model/Table/SitesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ public function validationDefault(Validator $validator): Validator
->maxLength('alias', 50, __d('baser_core', 'エイリアスは50文字以内で入力してください。'))
->notEmptyString('alias', __d('baser_core', 'エイリアスを入力してください。'))
->add('alias', [
'nameAlphaNumericPlus' => [
'rule' => ['alphaNumericPlus'],
'provider' => 'bc',
'checkSiteAlias' => [
'rule' => ['checkSiteAlias'],
'provider' => 'site',
'message' => __d('baser_core', 'エイリアスは、半角英数・ハイフン(-)・アンダースコア(_)で入力してください。')
]]);
$validator
Expand Down Expand Up @@ -801,5 +801,4 @@ public function save(
}
return $success;
}

}
40 changes: 0 additions & 40 deletions plugins/baser-core/src/Model/Validation/SiteConfigValidation.php

This file was deleted.

20 changes: 20 additions & 0 deletions plugins/baser-core/src/Model/Validation/SiteValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,24 @@ public static function checkContentExists($alias, $context)
return !((bool) $query->count());
}

/**
* サイトエリアスをバリデーション
* ドメインタイプが外部ドメインの場合、
* 英数、ハイフン、アンダースコア以外スラッシュ(/)・ドット(.)も許容
*
* @param $value
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public static function checkSiteAlias($value, $context)
{
if ($context['data']['use_subdomain'] == 0 && !BcValidation::alphaNumericPlus($value, '/')) {
return 'エイリアスは、半角英数・ハイフン(-)・アンダースコア(_)・スラッシュ(/)で入力してください。';
} elseif ($context['data']['use_subdomain'] == 1 && !BcValidation::alphaNumericPlus($value, '.')) {
return 'サブドメインや外部ドメインを利用する場合、エイリアスは、半角英数・ハイフン(-)・アンダースコア(_)・ドット(.)で入力してください。';
}
return true;
}
}
6 changes: 1 addition & 5 deletions plugins/baser-core/src/Routing/Route/BcContentsRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ public function parse($url, $method): ?array
$site = $sites->findByUrl($url);
if ($site && !is_null($site->name)) {
if ($site->use_subdomain) {
if (str_starts_with($url, '/' . $site->alias)) {
$checkUrl = $url;
} else {
$checkUrl = '/' . $site->alias . (($url)? $url : '/');
}
$checkUrl = '/' . $site->alias . (($url) ? $url : '/');
} else {
$checkUrl = ($url)? $url : '/';
}
Expand Down
32 changes: 21 additions & 11 deletions plugins/baser-core/src/Service/Admin/PluginsAdminService.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,27 @@ public function getViewVarsForUpdate(EntityInterface $entity): array
$dbVersion = BcUtil::getDbVersion($entity->name);
BcUtil::includePluginClass($entity->name);
$plugin = CakePlugin::getCollection()->create($entity->name);
$scriptNum = count($plugin->getUpdaters('', true));
$scriptMessages = $plugin->getUpdateScriptMessages('', true);
$coreDownloaded = Cache::read('coreDownloaded', '_bc_update_');

if ($entity->name === 'BaserCore') {
$availableVersion = $this->getAvailableCoreVersion();
$corePlugins = Configure::read('BcApp.corePlugins');
foreach($corePlugins as $corePlugin) {
$scriptNum += count($plugin->getUpdaters($corePlugin, true));
$scriptMessages += $plugin->getUpdateScriptMessages($corePlugin, true);
$availableVersion = null;
$scriptNum = $scriptMessages = [];
if($coreDownloaded) {
$availableVersion = BcUtil::getVersion('BaserCore', true);
$scriptNum = count($plugin->getUpdaters('', true));
$scriptMessages = $plugin->getUpdateScriptMessages('', true);
$corePlugins = Configure::read('BcApp.corePlugins');
foreach($corePlugins as $corePlugin) {
$scriptNum += count($plugin->getUpdaters($corePlugin, true));
$scriptMessages += $plugin->getUpdateScriptMessages($corePlugin, true);
}
}
if(!$availableVersion) {
$availableVersion = $this->getAvailableCoreVersion();
}
} else {
$scriptNum = count($plugin->getUpdaters());
$scriptMessages = $plugin->getUpdateScriptMessages();
$availableVersion = null;
}

Expand Down Expand Up @@ -101,7 +111,7 @@ public function getViewVarsForUpdate(EntityInterface $entity): array
'programVerPoint' => $programVerPoint,
'availableVersion' => $availableVersion,
'log' => $this->getUpdateLog(),
'coreDownloaded' => Cache::read('coreDownloaded', '_bc_update_'),
'coreDownloaded' => $coreDownloaded,
'php' => $this->whichPhp(),
'isCore' => $entity->name === 'BaserCore',
'isWritableVendor' => $isWritableVendor,
Expand Down Expand Up @@ -149,12 +159,12 @@ public function isRequireUpdate(string $programVersion, ?string $dbVersion, ?str

if(is_null($availableVersion)) {
// プラグインの場合 プログラムのバージョンを利用可能なバージョンとする
$availableVersion = $programVersion;
$availableVerPoint = $programVerPoint;
} else {
// コアの場合は、プログラムのバージョンとDBのバージョンが違う場合はアップデート不可
if ($programVersion !== $dbVersion) return false;
if ($programVerPoint !== $dbVerPoint) return false;
}
if ($availableVersion !== $dbVersion) return true;
if ($availableVerPoint > $dbVerPoint) return true;
return false;
}

Expand Down
Loading

0 comments on commit 3c825c5

Please sign in to comment.