Skip to content

Commit 352a067

Browse files
committed
Fix missing language data when saving blog posts
1 parent 5eab267 commit 352a067

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

controllers/admin/AdminEverpsBlogPostController.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,29 @@ public function postProcess()
11341134
);
11351135
}
11361136
}
1137+
// Copy default language values to empty translations
1138+
$defaultLang = (int) Configuration::get('PS_LANG_DEFAULT');
1139+
foreach (Language::getLanguages(false) as $lang) {
1140+
$idLang = (int) $lang['id_lang'];
1141+
if (empty($post->title[$idLang])) {
1142+
$post->title[$idLang] = $post->title[$defaultLang] ?? '';
1143+
}
1144+
if (empty($post->content[$idLang])) {
1145+
$post->content[$idLang] = $post->content[$defaultLang] ?? '';
1146+
}
1147+
if (empty($post->excerpt[$idLang])) {
1148+
$post->excerpt[$idLang] = $post->excerpt[$defaultLang] ?? '';
1149+
}
1150+
if (empty($post->meta_title[$idLang])) {
1151+
$post->meta_title[$idLang] = $post->meta_title[$defaultLang] ?? '';
1152+
}
1153+
if (empty($post->meta_description[$idLang])) {
1154+
$post->meta_description[$idLang] = $post->meta_description[$defaultLang] ?? '';
1155+
}
1156+
if (empty($post->link_rewrite[$idLang])) {
1157+
$post->link_rewrite[$idLang] = $post->link_rewrite[$defaultLang] ?? '';
1158+
}
1159+
}
11371160
if (!count($this->errors)) {
11381161
try {
11391162
$post->save();

0 commit comments

Comments
 (0)