fix(import): guard epoch-0 datetimes for MySQL 5.7 TIMESTAMP range
This commit is contained in:
@@ -224,7 +224,7 @@ class SablogImport extends Command
|
|||||||
'regip' => $row['regip'] ?: null,
|
'regip' => $row['regip'] ?: null,
|
||||||
'logintime' => $row['logintime'] ? date('Y-m-d H:i:s', (int) $row['logintime']) : null,
|
'logintime' => $row['logintime'] ? date('Y-m-d H:i:s', (int) $row['logintime']) : null,
|
||||||
'lastpost_at' => $row['lastpost'] ? date('Y-m-d H:i:s', (int) $row['lastpost']) : null,
|
'lastpost_at' => $row['lastpost'] ? date('Y-m-d H:i:s', (int) $row['lastpost']) : null,
|
||||||
'created_at' => date('Y-m-d H:i:s', (int) $row['regdateline']),
|
'created_at' => ($ts = (int) $row['regdateline']) > 0 ? date('Y-m-d H:i:s', $ts) : now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ class SablogImport extends Command
|
|||||||
foreach ($this->rows('articles') as $row) {
|
foreach ($this->rows('articles') as $row) {
|
||||||
$slug = SlugGenerator::make($row['title'], 'posts', 'slug', ignoreId: (int) $row['articleid'], fallback: 'post-'.$row['articleid']);
|
$slug = SlugGenerator::make($row['title'], 'posts', 'slug', ignoreId: (int) $row['articleid'], fallback: 'post-'.$row['articleid']);
|
||||||
$status = (int) $row['visible'] === 1 ? 'published' : 'draft';
|
$status = (int) $row['visible'] === 1 ? 'published' : 'draft';
|
||||||
$dateline = date('Y-m-d H:i:s', (int) $row['dateline']);
|
$dateline = ($ts = (int) $row['dateline']) > 0 ? date('Y-m-d H:i:s', $ts) : now()->toDateTimeString();
|
||||||
|
|
||||||
DB::table('posts')->updateOrInsert(['id' => (int) $row['articleid']], [
|
DB::table('posts')->updateOrInsert(['id' => (int) $row['articleid']], [
|
||||||
'category_id' => (int) $row['cid'] ?: null,
|
'category_id' => (int) $row['cid'] ?: null,
|
||||||
@@ -325,7 +325,7 @@ class SablogImport extends Command
|
|||||||
'content' => $row['content'],
|
'content' => $row['content'],
|
||||||
'ip' => $row['ipaddress'] ?: null,
|
'ip' => $row['ipaddress'] ?: null,
|
||||||
'status' => (int) $row['visible'] === 1 ? 'published' : 'pending',
|
'status' => (int) $row['visible'] === 1 ? 'published' : 'pending',
|
||||||
'created_at' => date('Y-m-d H:i:s', (int) $row['dateline']),
|
'created_at' => ($ts = (int) $row['dateline']) > 0 ? date('Y-m-d H:i:s', $ts) : null,
|
||||||
]);
|
]);
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user