Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1770 メールフィールドの数が多い場合に、受信データ用テーブルのフィールドが不足状態で作成されるケースが発生する点を改修 #1771

Merged
merged 2 commits into from
Nov 20, 2021
Merged
15 changes: 14 additions & 1 deletion lib/Baser/Plugin/Mail/Model/MailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -912,12 +912,25 @@ public function construction($mailContentId)
$this->cacheSources = false;
ClassRegistry::flush();
$schema = $this->schema();
$mailFieldNameList = [];

$messageFields = array_keys($schema);
foreach($mailFields as $mailField) {
if (!in_array($mailField['MailField']['field_name'], $messageFields)) {
$this->addMessageField($mailContentId, $mailField['MailField']['field_name']);
$mailFieldNameList[$mailField['MailField']['field_name']] = [
'type' => 'text', 'null' => null, 'default' => null, 'length' => null,
];
}
}

if ($this->tableExists($this->createFullTableName($mailContentId))) {
// 初回時にid,created,modifiedカラムを持つテーブルが作成されている
$this->dropTable($mailContentId);
$db = $this->getDataSource();
// id,create,modifiedカラムとフォームのメールフィールド全部を併せたテーブルを作る
$db->createTable(['schema' => array_merge($schema, $mailFieldNameList), 'table' => $this->createFullTableName($mailContentId)]);
$this->deleteModelCache();
}
}
return true;
}
Expand Down