Skip to content

Commit

Permalink
Merge branch 'dev-5' into pr/2819
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Nov 17, 2023
2 parents f7aac15 + 2a38c16 commit 5b78027
Show file tree
Hide file tree
Showing 102 changed files with 1,589 additions and 1,186 deletions.
235 changes: 118 additions & 117 deletions composer.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<ini name="apc.enable_cli" value="1"/>
</php>
<testsuites>
<testsuite name="BaserCore">
<directory>plugins/baser-core/tests/TestCase</directory>
</testsuite>
<testsuite name="BcBlog">
<directory>plugins/bc-blog/tests/TestCase</directory>
</testsuite>
<testsuite name="BcContentLink">
<directory>plugins/bc-content-link/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BaserCore">-->
<!-- <directory>plugins/baser-core/tests/TestCase</directory>-->
<!-- </testsuite>-->
<!-- <testsuite name="BcBlog">-->
<!-- <directory>plugins/bc-blog/tests/TestCase</directory>-->
<!-- </testsuite>-->
<!-- <testsuite name="BcContentLink">-->
<!-- <directory>plugins/bc-content-link/tests/TestCase</directory>-->
<!-- </testsuite>-->
<testsuite name="BcCustomContent">
<directory>plugins/bc-custom-content/tests/TestCase</directory>
</testsuite>
Expand All @@ -27,15 +27,15 @@
<!-- <testsuite name="BcFavorite">-->
<!-- <directory>plugins/bc-favorite/tests/TestCase</directory>-->
<!-- </testsuite>-->
<testsuite name="BcInstaller">
<directory>plugins/bc-installer/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcInstaller">-->
<!-- <directory>plugins/bc-installer/tests/TestCase</directory>-->
<!-- </testsuite>-->
<!-- <testsuite name="BcMail">-->
<!-- <directory>plugins/bc-mail/tests/TestCase</directory>-->
<!-- </testsuite>-->
<testsuite name="BcSearchIndex">
<directory>plugins/bc-search-index/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcSearchIndex">-->
<!-- <directory>plugins/bc-search-index/tests/TestCase</directory>-->
<!-- </testsuite>-->
<!-- <testsuite name="BcThemeConfig">-->
<!-- <directory>plugins/bc-theme-config/tests/TestCase</directory>-->
<!-- </testsuite>-->
Expand Down
4 changes: 2 additions & 2 deletions plugins/baser-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<a href="LICENSE" target="_blank">
<img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square">
</a>
<a href="https://github.com/baserproject/ucmitz/actions/workflows/test.yml" target="_blank">
<img alt="Build Status" src="https://github.com/baserproject/ucmitz/actions/workflows/test.yml/badge.svg?branch=dev">
<a href="https://github.com/baserproject/basercms/actions/workflows/test.yml" target="_blank">
<img alt="Build Status" src="https://github.com/baserproject/basercms/actions/workflows/test.yml/badge.svg?branch=dev-5">
</a>
</p>

Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
5.0.6
5.0.7-dev

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/config/bc_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
'radioWrapper' => '<span class="{{class}}">{{label}}</span>',
'radioFormGroup' => '<span class="{{groupClass}}">{{input}}</span>',
// Textarea input element,
'textarea' => '<textarea name="{{name}}"{{attrs}}>{{value}}</textarea>',
'textarea' => "<textarea name=\"{{name}}\"{{attrs}}>\n{{value}}\n</textarea>",
// Container for submit buttons.
// 'submitContainer' => '<div class="submit">{{content}}</div>' NOTE: formAfterCreateにてデザインが崩れるため一旦コメントアウト
'submitContainer' => '{{content}}',
Expand Down
22 changes: 11 additions & 11 deletions plugins/baser-core/src/Controller/Admin/SitesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
use BaserCore\Service\Admin\SitesAdminServiceInterface;
use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\Service\SitesServiceInterface;
use BaserCore\Service\ThemesServiceInterface;
use BaserCore\Utility\BcSiteConfig;
use Cake\Core\Exception\Exception;
use BaserCore\Annotation\Note;
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\UnitTest;
use Cake\Http\Exception\NotFoundException;
use Cake\ORM\Exception\PersistenceFailedException;
use Psr\Http\Message\ResponseInterface;

/**
Expand Down Expand Up @@ -66,11 +68,15 @@ public function index(SitesAdminServiceInterface $service)
* サイト追加
*
* @param SiteConfigsServiceInterface $service
* @return void|ResponseInterface
* @checked
* @unitTest
* @note(value="インストーラーを実装してからテーマの保有するプラグインをインストールする処理を追加する")
* @noTodo
*/
public function add(SitesAdminServiceInterface $service)
public function add(
SitesAdminServiceInterface $service,
ThemesServiceInterface $themesService
)
{
if ($this->request->is('post')) {

Expand All @@ -84,26 +90,20 @@ public function add(SitesAdminServiceInterface $service)

try {
$site = $service->create($this->request->getData());

// EVENT Sites.afterAdd
$this->dispatchLayerEvent('afterAdd', [
'data' => $site
]);

// TODO ucmitz 未実装のためコメントアウト
/* >>>
if (!empty($site->theme)) {
$this->BcManager->installThemesPlugins($site->theme);
}
<<< */

if ($site->theme) $themesService->installThemesPlugins($site->theme);
$this->BcMessage->setSuccess(sprintf(__d('baser_core', 'サイト「%s」を追加しました。'), $site->display_name));
return $this->redirect(['action' => 'edit', $site->id]);
} catch (\Cake\ORM\Exception\PersistenceFailedException $e) {
} catch (PersistenceFailedException $e) {
$site = $e->getEntity();
$this->BcMessage->setError(__d('baser_core', '入力エラーです。内容を修正してください。'));
}
}

$this->set($service->getViewVarsForAdd($site ?? $service->getNew()));
}

Expand Down
47 changes: 0 additions & 47 deletions plugins/baser-core/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public function beforeFilter(EventInterface $event)
$response = $this->redirectIfIsRequireMaintenance();
if ($response) return $response;

$this->__convertEncodingHttpInput();
$this->__cleanupQueryParams();

// インストーラー、アップデーターの場合はテーマを設定して終了
Expand Down Expand Up @@ -259,52 +258,6 @@ public function _blackHoleCallback($err, $exception)
throw new BadRequestException($message);
}

/**
* http経由で送信されたデータを変換する
* とりあえず、UTF-8で固定
*
* @return void
* @checked
* @noTodo
* @unitTest
*/
private function __convertEncodingHttpInput(): void
{
if ($this->getRequest()->getData()) {
$this->setRequest($this->request->withParsedBody($this->_autoConvertEncodingByArray($this->getRequest()->getData(), 'UTF-8')));
}
}

/**
* 配列の文字コードを変換する
*
* @param array $data 変換前データ
* @param string $outenc 変換後の文字コード
* @return array 変換後データ
* @checked
* @noTodo
* @unitTest
*/
protected function _autoConvertEncodingByArray($data, $outenc = 'UTF-8'): array
{
if (!$data) return [];
foreach($data as $key => $value) {
if (is_array($value)) {
$data[$key] = $this->_autoConvertEncodingByArray($value, $outenc);
continue;
}
$inenc = mb_detect_encoding((string)$value);
if (!$inenc) continue;
if (!in_array($inenc, Configure::read('BcEncode.detectOrder'))) continue;
if ($inenc === $outenc) continue;
// 半角カナは一旦全角に変換する
$value = mb_convert_kana($value, 'KV', $inenc);
$value = mb_convert_encoding($value, $outenc, $inenc);
$data[$key] = $value;
}
return $data;
}

/**
* クエリーパラメーターの調整
* 環境によって?キーにamp;が付加されてしまうため
Expand Down
9 changes: 1 addition & 8 deletions plugins/baser-core/src/Controller/BcFrontAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,11 @@ public function beforeFilter(EventInterface $event)
* Before Render
* @param EventInterface $event
* @checked
* @note(value="マイルストーン2が終わってから確認する")
* @noTodo
*/
public function beforeRender(EventInterface $event): void
{
parent::beforeRender($event);
// TODO ucmitz サイト名でサブフォルダを設定し、サブフォルダが存在しない場合は、通常のフォルダを参照できるようにする
// この部分もテストも実装要
// $subDir = $this->getRequest()->getAttribute('currentSite')->name;
// if ($subDir) {
// $this->viewBuilder()->setLayoutPath($subDir);
// $this->viewBuilder()->setTemplatePath($this->getName() . DS . $subDir);
// }
if (BcUtil::isInstalled()) {
// ショートコード
$this->getEventManager()->on(new BcShortCodeEventListener());
Expand Down
17 changes: 8 additions & 9 deletions plugins/baser-core/src/Middleware/BcRequestFilterMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ public function process(
RequestHandlerInterface $handler
): ResponseInterface
{
$request = $this->addDetectors($request);
if(BcUtil::isInstalled()) {
$response = $this->redirectIfIsDeviceFile($request);
if($response) return $response;
}

if ($this->isAsset($request)) {
Configure::write('BcRequest.asset', true);
return new Response();
}

$request = $this->addDetectors($request);

/**
* CGIモード等PHPでJWT認証で必要なAuthorizationヘッダーが取得出来ないできない場合、REDIRECT_HTTP_AUTHORIZATION環境変数より取得する
* .htaccess等に下記を記載することで動作可能とする
Expand All @@ -60,8 +65,6 @@ public function process(
$request = $request->withHeader('Authorization', $request->getEnv('REDIRECT_HTTP_AUTHORIZATION'));
}

if(BcUtil::isInstalled()) $this->redirectIfIsDeviceFile($request, $handler);

return $handler->handle($request);
}

Expand All @@ -72,17 +75,13 @@ public function process(
* CMSで作成するページ内のリンクは、モバイルでアクセスすると、自動的に、/m/ 付のリンクに書き換えられてしまう為、
* files内のファイルへのリンクがリンク切れになってしまうので暫定対策。
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface|void
* @checked
* @unitTest
* @note(value="マイルストーン3が終わってから動作確認する")
* @noTodo
*/
public function redirectIfIsDeviceFile(
ServerRequestInterface $request,
RequestHandlerInterface $handler)
public function redirectIfIsDeviceFile(ServerRequestInterface $request)
{
// TODO ucmitz ユニットテストでしか動作確認していない
$sites = \Cake\ORM\TableRegistry::getTableLocator()->get('BaserCore.Sites');
$site = $sites->findByUrl($request->getPath());
if ($site && $site->device) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public function services(ContainerInterface $container): void
* @param CommandCollection $commands
* @return CommandCollection
* @checked
* @checked
* @noTodo
*/
public function console(CommandCollection $commands): CommandCollection
{
Expand Down
27 changes: 1 addition & 26 deletions plugins/baser-core/src/Service/BcDatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,31 +614,6 @@ public function initSystemData($options = []): bool
return $result;
}

/**
* メールメッセージテーブルを初期化する
*
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function initMessageTables(): bool
{
// TODO ucmitz メールプラグイン未実装のため
return true;
BcUtil::clearAllCache();
// メール受信テーブルの作成
$MailMessage = new MailMessage();
$result = true;
if (!$MailMessage->reconstructionAll()) {
$this->log(__d('baser_core', 'メールプラグインのメール受信用テーブルの生成に失敗しました。'));
$result = false;
}
BcUtil::clearAllCache();
TableRegistry::getTableLocator()->clear();
return $result;
}

/**
* データベースシーケンスをアップデートする
* @checked
Expand Down Expand Up @@ -1381,6 +1356,7 @@ public function checkDbConnection($config)
*
* @checked
* @unitTest
* @noTodo
*/
public function testConnectDb($config)
{
Expand Down Expand Up @@ -1418,7 +1394,6 @@ public function testConnectDb($config)
}
break;
case 'Cake\Database\Driver\Postgres' :
// TODO ucmitz 未検証
$result = $db->query("SELECT version() as version")->fetch();
[, $version] = explode(" ", $result[0]);
if (version_compare(trim($version), Configure::read('BcRequire.PostgreSQLVersion')) == -1) {
Expand Down
20 changes: 5 additions & 15 deletions plugins/baser-core/src/Service/BcDatabaseServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface BcDatabaseServiceInterface

/**
* 初期データを読み込む
*
*
* @param $theme
* @param $pattern
* @param $excludes
Expand Down Expand Up @@ -75,7 +75,7 @@ public function resetTables($plugin = 'BaserCore', $excludes = []): bool;

/**
* テーブルのデータをリセットする
*
*
* @param $table
* @return bool
* @noTodo
Expand All @@ -94,19 +94,9 @@ public function truncate($table): bool;
*/
public function initSystemData($options = []): bool;

/**
* メールメッセージテーブルを初期化する
*
* @return bool
* @noTodo
* @checked
* @unitTest
*/
public function initMessageTables(): bool;

/**
* データベースシーケンスをアップデートする
*
*
* @noTodo
* @checked
* @unitTest
Expand Down Expand Up @@ -161,7 +151,7 @@ public function getAppTableList($plugin = ''): array;

/**
* アプリケーションに関連するテーブルリストのキャッシュをクリアする
*
*
* @checked
* @noTodo
* @unitTest
Expand All @@ -183,7 +173,7 @@ public function writeSchema($table, $options);

/**
* スキーマを読み込む
*
*
* @param $options
* @return bool
* @unitTest
Expand Down
Loading

0 comments on commit 5b78027

Please sign in to comment.