Skip to content

Commit

Permalink
Merge branch 'dev-5' into dev-#2773
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Oct 27, 2023
2 parents 3d14799 + d84c1d1 commit 6edd143
Show file tree
Hide file tree
Showing 31 changed files with 376 additions and 1,313 deletions.
32 changes: 16 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@
}
},
"replace": {
"baserproject/baser-core": "5.0.5",
"baserproject/bc-admin-third": "5.0.5",
"baserproject/bc-blog": "5.0.5",
"baserproject/bc-column": "5.0.5",
"baserproject/bc-content-link": "5.0.5",
"baserproject/bc-custom-content": "5.0.5",
"baserproject/bc-editor-template": "5.0.5",
"baserproject/bc-favorite": "5.0.5",
"baserproject/bc-front": "5.0.5",
"baserproject/bc-installer": "5.0.5",
"baserproject/bc-mail": "5.0.5",
"baserproject/bc-search-index": "5.0.5",
"baserproject/bc-theme-config": "5.0.5",
"baserproject/bc-theme-file": "5.0.5",
"baserproject/bc-uploader": "5.0.5",
"baserproject/bc-widget-area": "5.0.5"
"baserproject/baser-core": "5.0.6",
"baserproject/bc-admin-third": "5.0.6",
"baserproject/bc-blog": "5.0.6",
"baserproject/bc-column": "5.0.6",
"baserproject/bc-content-link": "5.0.6",
"baserproject/bc-custom-content": "5.0.6",
"baserproject/bc-editor-template": "5.0.6",
"baserproject/bc-favorite": "5.0.6",
"baserproject/bc-front": "5.0.6",
"baserproject/bc-installer": "5.0.6",
"baserproject/bc-mail": "5.0.6",
"baserproject/bc-search-index": "5.0.6",
"baserproject/bc-theme-config": "5.0.6",
"baserproject/bc-theme-file": "5.0.6",
"baserproject/bc-uploader": "5.0.6",
"baserproject/bc-widget-area": "5.0.6"
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<testsuite name="BcSearchIndex">
<directory>plugins/bc-search-index/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcThemeConfig">-->
<!-- <directory>plugins/bc-theme-config/tests/TestCase</directory>-->
<!-- </testsuite>-->
<testsuite name="BcThemeConfig">
<directory>plugins/bc-theme-config/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcThemeFile">-->
<!-- <directory>plugins/bc-theme-file/tests/TestCase</directory>-->
<!-- </testsuite>-->
Expand Down
9 changes: 8 additions & 1 deletion plugins/baser-core/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
5.0.5
5.0.7-dev

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
Expand All @@ -14,6 +14,13 @@
CHG: 変更内容 / BUG: バグフィックス / NEW: 機能追加


[2023-10-26] basercms-5.0.6
- BUG [BC] fix #1903 コンテンツ一覧(表)コピーの際にコピー先のタイトルに「のコピー」とつかない問題の改善
- BUG [BC] fix #2783 CGIモードでJWT認証が可能なよう改善
- BUG [BC] fix #2403 アップロードファイルのAPIにフルパスのURLを追加
- BUG [ML] fix #1901 バリデーションエラー時にチェックボックスのチェックが外れる
- BUG [ML] fix #2806 メールプラグインが有効化されていない場合にダッシュボードが表示できない問題の改善

[2023-09-28] basercms-5.0.5
- BUG [BC] fix #2744 カスタムコンテンツのバリデーションエラーを改善
- BUG [BC] fix #2199 カスタムコンテンツのAPIで取得する情報に不要な連携データが含まれる処理の改善
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace BaserCore\Controller\Admin;

use Authentication\Controller\Component\AuthenticationComponent;
use BaserCore\Controller\BcAppController;
use BaserCore\Controller\AppController;
use BaserCore\Service\Admin\BcAdminAppServiceInterface;
use BaserCore\Service\SiteConfigsService;
use BaserCore\Service\SiteConfigsServiceInterface;
Expand All @@ -34,7 +34,7 @@
* Class BcAdminAppController
* @property AuthenticationComponent $Authentication
*/
class BcAdminAppController extends BcAppController
class BcAdminAppController extends AppController
{

/**
Expand Down
83 changes: 63 additions & 20 deletions plugins/baser-core/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\Note;
use BaserCore\Service\AppServiceInterface;
use BaserCore\Service\DblogsServiceInterface;
use BaserCore\Service\PermissionsServiceInterface;
use BaserCore\Utility\BcContainerTrait;
use BaserCore\Utility\BcSiteConfig;
Expand All @@ -35,6 +36,7 @@
use Cake\Http\ServerRequest;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
use Psr\Http\Message\ResponseInterface;

/**
* Class AppController
Expand All @@ -50,22 +52,23 @@ class AppController extends BaseController
use BcContainerTrait;

/**
* BcAppController constructor.
* AppController constructor.
* @param ServerRequest|null $request
* @param Response|null $response
* @param string|null $name
* @param EventManagerInterface|null $eventManager
* @param ComponentRegistry|null $components
* @return void|ResponseInterface
* @checked
* @noTodo
* @unitTest
*/
public function __construct(
?ServerRequest $request = null,
?Response $response = null,
?string $name = null,
?ServerRequest $request = null,
?Response $response = null,
?string $name = null,
?EventManagerInterface $eventManager = null,
?ComponentRegistry $components = null
?ComponentRegistry $components = null
)
{
parent::__construct($request, $response, $name, $eventManager, $components);
Expand All @@ -78,10 +81,10 @@ public function __construct(
if (!($request? $request->is('install') : false)) {
// app_local.php が存在しない場合は、CakePHPの Internal Server のエラー画面が出て、
// 原因がわからなくなるので強制的にコピーする
if($this->getName() === 'BcError' && !file_exists(CONFIG . 'app_local.php')) {
if ($this->getName() === 'BcError' && !file_exists(CONFIG . 'app_local.php')) {
copy(CONFIG . 'app_local.example.php', CONFIG . 'app_local.php');
// app_local.php が存在しない場合、.env もない可能性があるので確認
if(!file_exists(CONFIG . '.env')){
if (!file_exists(CONFIG . '.env')) {
copy(CONFIG . '.env.example', CONFIG . '.env');
}
}
Expand All @@ -101,7 +104,6 @@ public function __construct(
}
}
}

}

/**
Expand Down Expand Up @@ -134,13 +136,13 @@ public function initialize(): void
public function beforeFilter(EventInterface $event)
{
$response = parent::beforeFilter($event);
if($response) return $response;
if ($response) return $response;

// index.php をつけたURLの場合、base の値が正常でなくなり、
// 内部リンクが影響を受けておかしくなってしまうため強制的に Not Found とする
if(preg_match('/\/index\.php\//', $this->getRequest()->getAttribute('base'))) {
$this->notFound();
}
// index.php をつけたURLの場合、base の値が正常でなくなり、
// 内部リンクが影響を受けておかしくなってしまうため強制的に Not Found とする
if (preg_match('/\/index\.php\//', $this->getRequest()->getAttribute('base'))) {
$this->notFound();
}

if (!$this->getRequest()->is('requestview')) return;

Expand All @@ -157,21 +159,21 @@ public function beforeFilter(EventInterface $event)
return;
}

if(!$this->checkPermission()) {
if (!$this->checkPermission()) {
$prefix = BcUtil::getRequestPrefix($this->getRequest());
if ($prefix === 'Api/Admin') {
throw new ForbiddenException(__d('baser_core', '指定されたAPIエンドポイントへのアクセスは許可されていません。'));
} else {
if (BcUtil::loginUser()) {
if($this->getRequest()->getMethod() === 'GET') {
if ($this->getRequest()->getMethod() === 'GET') {
$this->BcMessage->setError(__d('baser_core', '指定されたページへのアクセスは許可されていません。'));
} else {
$this->BcMessage->setError(__d('baser_core', '実行した操作は許可されていません。'));
}
}
// リファラが存在する場合はリファラにリダイレクトする
// $this->referer() で判定した場合、リファラがなくてもトップのURLが返却されるため ServerRequest で判定
if($this->getRequest()->getEnv('HTTP_REFERER')) {
if ($this->getRequest()->getEnv('HTTP_REFERER')) {
$url = $this->referer();
} else {
$url = Configure::read("BcPrefixAuth.{$prefix}.loginRedirect");
Expand All @@ -197,7 +199,7 @@ public function beforeFilter(EventInterface $event)
private function checkPermission()
{
$user = BcUtil::loginUser();
if($user && $user->user_groups) {
if ($user && $user->user_groups) {
$userGroupsIds = Hash::extract($user->toArray()['user_groups'], '{n}.id');
} else {
$userGroupsIds = [];
Expand Down Expand Up @@ -269,8 +271,8 @@ protected function _autoConvertEncodingByArray($data, $outenc = 'UTF-8'): array
continue;
}
$inenc = mb_detect_encoding((string)$value);
if(!$inenc) continue;
if(!in_array($inenc, Configure::read('BcEncode.detectOrder'))) continue;
if (!$inenc) continue;
if (!in_array($inenc, Configure::read('BcEncode.detectOrder'))) continue;
if ($inenc === $outenc) continue;
// 半角カナは一旦全角に変換する
$value = mb_convert_kana($value, 'KV', $inenc);
Expand Down Expand Up @@ -510,4 +512,45 @@ public function notFound()
throw new NotFoundException(__d('baser_core', '見つかりませんでした。'));
}

/**
* データベースログを記録する
*
* @param string $message
* @return \Cake\Datasource\EntityInterface
* @checked
* @unitTest
* @noTodo
*/
protected function saveDblog($message)
{
$dblogsService = $this->getService(DblogsServiceInterface::class);
return $dblogsService->create(['message' => $message]);
}

/**
* Ajax用のエラーを出力する
*
* @param int $errorNo エラーのステータスコード
* @param mixed $message エラーメッセージ
* @return void
* @deprecated since 5.0.5 このメソッドは非推奨です。
* @checked
* @noTodo
*/
public function ajaxError(int $errorNo = 500, $message = '')
{
$this->response = $this->getResponse()->withStatus($errorNo);
if (!$message) return;
if (!is_array($message)) $message = [$message];
$aryMessage = [];
foreach($message as $value) {
if (is_array($value)) {
$aryMessage[] = implode('<br />', $value);
} else {
$aryMessage[] = $value;
}
}
echo implode('<br>', $aryMessage);
}

}
Loading

0 comments on commit 6edd143

Please sign in to comment.