Skip to content

Commit

Permalink
Merge branch '5.1.x' into tfa
Browse files Browse the repository at this point in the history
# Conflicts:
#	plugins/baser-core/config/setting.php
  • Loading branch information
seto1 committed Jul 8, 2024
2 parents 11725c3 + d509c9a commit c9f2988
Show file tree
Hide file tree
Showing 82 changed files with 605 additions and 404 deletions.
38 changes: 17 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@
"BcInstaller\\": "plugins/bc-installer/src/",
"BcMail\\": "plugins/bc-mail/src/",
"BcSearchIndex\\": "plugins/bc-search-index/src/",
"BcSpaSample\\": "plugins/BcSpaSample/src/",
"BcThemeConfig\\": "plugins/bc-theme-config/src/",
"BcThemeFile\\": "plugins/bc-theme-file/src/",
"BcUploader\\": "plugins/bc-uploader/src/",
"BcWidgetArea\\": "plugins/bc-widget-area/src/",
"Cake\\Routing\\": "plugins/baser-core/src/Routing",
"SoftDelete\\": "plugins/cakephp-soft-delete/src"
"Cake\\Routing\\": "plugins/baser-core/src/Routing"
}
},
"autoload-dev": {
Expand All @@ -74,27 +72,25 @@
"BcThemeConfig\\Test\\": "plugins/bc-theme-config/tests/",
"BcThemeFile\\Test\\": "plugins/bc-theme-file/tests/",
"BcUploader\\Test\\": "plugins/bc-uploader/tests/",
"BcWidgetArea\\Test\\": "plugins/bc-widget-area/tests/",
"SoftDelete\\Test\\": "plugins/cakephp-soft-delete/tests"
"BcWidgetArea\\Test\\": "plugins/bc-widget-area/tests/"
}
},
"replace": {
"baserproject/baser-core": "5.0.18",
"baserproject/bc-admin-third": "5.0.18",
"baserproject/bc-blog": "5.0.18",
"baserproject/bc-column": "5.0.18",
"baserproject/bc-content-link": "5.0.18",
"baserproject/bc-custom-content": "5.0.18",
"baserproject/bc-editor-template": "5.0.18",
"baserproject/bc-favorite": "5.0.18",
"baserproject/bc-front": "5.0.18",
"baserproject/bc-installer": "5.0.18",
"baserproject/bc-mail": "5.0.18",
"baserproject/bc-search-index": "5.0.18",
"baserproject/bc-theme-config": "5.0.18",
"baserproject/bc-theme-file": "5.0.18",
"baserproject/bc-uploader": "5.0.18",
"baserproject/bc-widget-area": "5.0.18"
"baserproject/baser-core": "5.0.19",
"baserproject/bc-admin-third": "5.0.19",
"baserproject/bc-blog": "5.0.19",
"baserproject/bc-content-link": "5.0.19",
"baserproject/bc-custom-content": "5.0.19",
"baserproject/bc-editor-template": "5.0.19",
"baserproject/bc-favorite": "5.0.19",
"baserproject/bc-front": "5.0.19",
"baserproject/bc-installer": "5.0.19",
"baserproject/bc-mail": "5.0.19",
"baserproject/bc-search-index": "5.0.19",
"baserproject/bc-theme-config": "5.0.19",
"baserproject/bc-theme-file": "5.0.19",
"baserproject/bc-uploader": "5.0.19",
"baserproject/bc-widget-area": "5.0.19"
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
Expand Down
1 change: 0 additions & 1 deletion config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ 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
3 changes: 2 additions & 1 deletion monorepo-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

return static function (MBConfig $mbConfig): void {
$mbConfig->packageDirectories([__DIR__ . '/plugins']);
$version = (!empty($_SERVER['argv'][2]))?: '';
$version = (!empty($_SERVER['argv'][2]))? $_SERVER['argv'][2] : '';
if(!$version) return;
$mbConfig->packageDirectoriesExcludes([
__DIR__ . '/plugins/BcThemeSample',
__DIR__ . '/plugins/BcPluginSample',
__DIR__ . '/plugins/BcColumn',
]);
// for "merge" command
$mbConfig->dataToAppend([
Expand Down
13 changes: 0 additions & 13 deletions plugins/BcColumn/composer.json

This file was deleted.

17 changes: 17 additions & 0 deletions plugins/baser-core/VERSION.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@
CHG: 変更内容 / BUG: バグフィックス / NEW: 機能追加


[2024-06-27] basercms-5.0.19
- CHG [BC] Cake\ORM\Table::find()の前後にイベントを追加
- CHG [BC] BcFormHelperのcontrolメソッドに beforeControl追加
- CHG [BC] アップデーター取得、アップデートメッセージ取得について、アップデート用の一時ディレクトリを確認するオプションを追加
- CHG [UL] アップロードカテゴリにページネーションのUIを追加
- BUG [BC] コンテンツの並び替え時に不用意な動作となってしまう問題を改善
- BUG [BC] コンテンツ管理ちらつき軽減
- BUG [BC] 管理画面ログイン後のリダイレクトが動作していない問題を改善 #3523
- BUG [BC] 【システム】管理画面でお気に入りの削除を行った直後にお気に入りの追加を行えない問題を改善 fix #3537
- BUG [BC] ごみ箱にファイルがある状態でツリー構造チェックを行うと常にエラーになる問題を修正 fix #3488
- BUG [BC] アップデーターを改善
- BUG [BC] windows 環境にてプラグインのアップロードが正常にできない問題について調整
- BUG [BC] 【固定ページ】$this->BcPage->getPageList() でフォルダに属するページのデータを取得できない問題を改善 fix #3527
- BUG [BC] BcZipでZipファイルを解凍する場合、ZipArchiveライブラリが入っていないと失敗する問題について改善
- BUG [BC] baserCMSコアのアップデートがxdebug不足により失敗する事象の修正 fix #3509
- BUG [UL] アップロードファイル・カテゴリ ページネーション調整

[2024-06-08] basercms-5.0.18
- CHG [BC] プラグインアップロードにて plugins ディレクトリの書き込み権限チェックを追加
- BUG [BC] アップデート通知が正常に表示できない問題を改善
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"cakephp/debug_kit": "^5.0.0",
"josegonzalez/dotenv": "^4.0",
"phpunit/phpunit": "^10.1.0",
"symplify/monorepo-builder": "^10.2",
"symplify/monorepo-builder": "^11.2",
"vierge-noire/cakephp-fixture-factories": "^3.0",
"vierge-noire/cakephp-test-suite-light": "^3.0",
"ext-xdebug": "*"
Expand Down
11 changes: 0 additions & 11 deletions plugins/baser-core/config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,6 @@
*/
'passwordRequestAllowTime' => 1440,

/**
* 二段階認証コードの有効時間(min)
*/
'twoFactorAuthenticationCodeAllowTime' => 10,

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

/**
* エディタ
*/
Expand Down Expand Up @@ -559,7 +549,6 @@
'defaultAllows' => [
'/baser/admin',
'/baser/admin/baser-core/users/login',
'/baser/admin/baser-core/users/login_code',
'/baser/admin/baser-core/users/logout',
'/baser/admin/baser-core/password_requests/*',
'/baser/admin/baser-core/dashboard/*',
Expand Down
17 changes: 10 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,20 @@

/**
* 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 = '';
if(\Cake\Core\Plugin::isLoaded('BcUpdateSupporter')) {
$message = "アップデート前に、BcUpdateSupporterプラグインを無効化してください。\n";
}
$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
];
8 changes: 0 additions & 8 deletions plugins/baser-core/src/BaserCorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,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 @@ -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
12 changes: 4 additions & 8 deletions plugins/baser-core/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\Routing\Router;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -169,15 +170,10 @@ public function beforeFilter(EventInterface $event)
} else {
$this->BcMessage->setError(__d('baser_core', '実行した操作は許可されていません。'));
}
}
// リファラが存在する場合はリファラにリダイレクトする
// $this->referer() で判定した場合、リファラがなくてもトップのURLが返却されるため ServerRequest で判定
if ($this->getRequest()->getEnv('HTTP_REFERER') &&
$this->getRequest()->getAttribute('here') !== $this->referer()
) {
$url = $this->referer();
} else {
$url = Configure::read("BcPrefixAuth.{$prefix}.loginRedirect");
} else {
$url = Router::url(Configure::read("BcPrefixAuth.{$prefix}.loginAction"))
. '?redirect=' . urlencode(Router::url());
}
return $this->redirect($url);
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/baser-core/src/Model/Entity/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function isCorePlugin()
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function isTheme()
{
Expand All @@ -104,6 +105,7 @@ public function isTheme()
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function isAdminTheme(): bool
{
Expand Down
4 changes: 3 additions & 1 deletion plugins/baser-core/src/Model/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ public function isEnableLoginAgent(EntityInterface $targetUser): bool
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function isDeletableUser(EntityInterface $targetUser): bool
{
return (($this->isSuper() && !$targetUser->isSuper()) ||
($this->isAdmin() && !$targetUser->isAdmin()));
($this->isAdmin() && !$targetUser->isAdmin()) && !$targetUser->isSuper());
}

/**
Expand All @@ -167,6 +168,7 @@ public function isDeletableUser(EntityInterface $targetUser): bool
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function isEditableUser(EntityInterface $targetUser): bool
{
Expand Down
36 changes: 36 additions & 0 deletions plugins/baser-core/src/Model/Table/AppTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use BaserCore\Utility\BcUtil;
use Cake\ORM\Association\BelongsToMany;
use Cake\ORM\Query;
use Cake\ORM\Table;
use Cake\I18n\FrozenTime;
use BaserCore\Annotation\NoTodo;
Expand Down Expand Up @@ -108,6 +109,41 @@ public function belongsToMany(string $associated, array $options = []): BelongsT
return parent::belongsToMany($associated, $options);
}

/**
* findの前後にイベントを追加する
*
* @param string $type the type of query to perform
* @param array<string, mixed> $options An array that will be passed to Query::applyOptions()
* @return \Cake\ORM\Query The query builder
* @checked
* @noTodo
*/
public function find(string $type = 'all', mixed ...$args): Query
{
// EVENT beforeFind
$event = $this->dispatchLayerEvent('beforeFind', [
'type' => $type,
'options' => $args // 後方互換のため options として渡す
]);
if ($event !== false) {
$args = ($event->getResult() === null || $event->getResult() === true) ? $event->getData('options') : $event->getResult();
}

$result = parent::find($type, ...$args);

// EVENT afterFind
$event = $this->dispatchLayerEvent('afterFind', [
'type' => $type,
'options' => $args,
'result' => $result
]);
if ($event !== false) {
$result = ($event->getResult() === null || $event->getResult() === true) ? $event->getData('result') : $event->getResult();
}

return $result;
}

/**
* テーブル名にプレフィックスを追加する
*
Expand Down
10 changes: 0 additions & 10 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 @@ -91,14 +89,6 @@ public function validationKeyValue(Validator $validator): 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を入力してください。')
]]);
return $validator;
}

Expand Down
1 change: 1 addition & 0 deletions plugins/baser-core/src/Model/Validation/BcValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ public static function checkSelectList($value): bool
* @param int $min 値の最短値
* @param int $max 値の最長値
* @param boolean
* @unitTest
*/
public static function between($value, $min, $max)
{
Expand Down
40 changes: 0 additions & 40 deletions plugins/baser-core/src/Model/Validation/SiteConfigValidation.php

This file was deleted.

Loading

0 comments on commit c9f2988

Please sign in to comment.