Skip to content

Commit

Permalink
テーマ初期値を読み込むとメールフィールドのフィールド名がエラーで編集できなくなる場合がある fix #2944
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Dec 22, 2023
1 parent b23715c commit 97f5b8c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 10 deletions.
11 changes: 11 additions & 0 deletions plugins/baser-core/src/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use BaserCore\Utility\BcZip;
use BcMail\Service\MailMessagesServiceInterface;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Datasource\EntityInterface;
use Cake\Filesystem\Folder;
use Cake\Log\LogTrait;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use Cake\Utility\Inflector;
Expand All @@ -39,6 +41,7 @@ class ThemesService implements ThemesServiceInterface
* Trait
*/
use BcContainerTrait;
use LogTrait;

/**
* 単一データ取得
Expand Down Expand Up @@ -313,6 +316,13 @@ public function loadDefaultDataPattern(string $currentTheme, string $dbDataPatte
throw $e;
}

/** @var MailMessagesServiceInterface $mailMessagesService */
$mailMessagesService = $this->getService(MailMessagesServiceInterface::class);
if (!$mailMessagesService->reconstructionAll()) {
$this->log(__d('baser_core', 'メールプラグインのメール受信用テーブルの生成に失敗しました。'));
$result = false;
}

// システムデータの初期化
if (!$dbService->initSystemData([
'excludeUsers' => true,
Expand All @@ -323,6 +333,7 @@ public function loadDefaultDataPattern(string $currentTheme, string $dbDataPatte
'theme' => $currentTheme,
'adminTheme' => BcSiteConfig::get('admin_theme')
])) {
$this->log(__d('baser_core', 'システムデータの初期化に失敗しました。'));
$result = false;
}

Expand Down
20 changes: 10 additions & 10 deletions plugins/baser-core/src/Service/ThemesServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface ThemesServiceInterface

/**
* 単一データ取得
*
*
* @param string $theme
* @return EntityInterface
* @checked
Expand All @@ -36,7 +36,7 @@ public function get(string $theme);

/**
* 一覧データ取得
*
*
* @checked
* @noTodo
* @unitTest
Expand All @@ -45,7 +45,7 @@ public function getIndex(): array;

/**
* 新しいテーマをアップロードする
*
*
* @param array $postData
* @return string
* @checked
Expand All @@ -56,7 +56,7 @@ public function add(array $postData): string;

/**
* テーマを適用する
*
*
* @param string $theme
* @checked
* @noTodo
Expand All @@ -66,18 +66,18 @@ public function apply(Site $site, string $theme): array;

/**
* 初期データを読み込む
*
*
* @param string $theme
* @param string $pattern
* @checked
* @noTodo
* @unitTest
*/
public function loadDefaultDataPattern(string $theme, string $pattern): bool;
public function loadDefaultDataPattern(string $currentTheme, string $dbDataPattern): bool;

/**
* コピーする
*
*
* @param string $theme
* @checked
* @noTodo
Expand All @@ -87,7 +87,7 @@ public function copy(string $theme): bool;

/**
* 削除する
*
*
* @checked
* @noTodo
* @unitTest
Expand All @@ -96,7 +96,7 @@ public function delete(string $theme): bool;

/**
* baserマーケットのテーマ一覧を取得する
*
*
* @checked
* @noTodo
* @unitTest
Expand All @@ -105,7 +105,7 @@ public function getMarketThemes(): array;

/**
* 指定したテーマをダウンロード用のテーマとして一時フォルダに作成する
*
*
* @param string $theme
* @return string
* @checked
Expand Down
29 changes: 29 additions & 0 deletions plugins/bc-mail/src/Service/MailMessagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,35 @@ public function construction(int $mailContentId): bool
return true;
}

/**
* 全てのメール受信テーブルの再構築を行う
* @return bool
*/
public function reconstructionAll(): bool
{
$mailContentsTable = TableRegistry::getTableLocator()->get('BcMail.MailContents');
$mailContents = $mailContentsTable->find()->all();
$mailContentsTable->getConnection()->begin();
$result = true;
foreach($mailContents as $mailContent) {
if ($this->createTable($mailContent->id)) {
if (!$this->construction($mailContent->id)) {
$result = false;
break;
}
} else {
$result = false;
break;
}
}
if($result) {
$mailContentsTable->getConnection()->commit();
} else {
$mailContentsTable->getConnection()->rollback();
}
return $result;
}

/**
* 初期値の設定をする
*
Expand Down
6 changes: 6 additions & 0 deletions plugins/bc-mail/src/Service/MailMessagesServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ public function renameMessageField(int $mailContentId, string $oldFieldName, str
*/
public function construction(int $mailContentId): bool;

/**
* 全てのメール受信テーブルの再構築を行う
* @return bool
*/
public function reconstructionAll(): bool;

/**
* 初期値の設定をする
*
Expand Down

0 comments on commit 97f5b8c

Please sign in to comment.