Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c361999ea8 | |||
| 0617f19c28 |
@@ -11,10 +11,10 @@
|
||||
"migration",
|
||||
"cloner"
|
||||
],
|
||||
"homepage": "https://git.file-archive.de/webfarben/DummyCopier",
|
||||
"homepage": "https://github.com/webfarben/DummyCopier",
|
||||
"support": {
|
||||
"source": "https://git.file-archive.de/webfarben/DummyCopier",
|
||||
"issues": "https://git.file-archive.de/webfarben/DummyCopier/issues"
|
||||
"source": "https://github.com/webfarben/DummyCopier",
|
||||
"issues": "https://github.com/webfarben/DummyCopier/issues"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
|
||||
@@ -164,6 +164,8 @@
|
||||
'moduleMap' => $this->result->moduleMap,
|
||||
'newsArchiveMap' => $this->result->newsArchiveMap,
|
||||
'calendarMap' => $this->result->calendarMap,
|
||||
'newsItemMap' => $this->result->newsItemMap,
|
||||
'eventMap' => $this->result->eventMap,
|
||||
'notes' => $this->result->notes,
|
||||
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), ENT_QUOTES, 'UTF-8'); ?></pre>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -327,11 +327,71 @@ final class DummyCopier
|
||||
$updates['cal_calendar'] = $this->remapSerializedIds((string) ($row['cal_calendar'] ?? ''), $result->calendarMap);
|
||||
}
|
||||
|
||||
if (array_key_exists('news_readerModule', $row)) {
|
||||
$oldReaderModuleId = (int) ($row['news_readerModule'] ?? 0);
|
||||
|
||||
if ($oldReaderModuleId > 0 && isset($result->moduleMap[$oldReaderModuleId])) {
|
||||
$updates['news_readerModule'] = $result->moduleMap[$oldReaderModuleId];
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('cal_readerModule', $row)) {
|
||||
$oldReaderModuleId = (int) ($row['cal_readerModule'] ?? 0);
|
||||
|
||||
if ($oldReaderModuleId > 0 && isset($result->moduleMap[$oldReaderModuleId])) {
|
||||
$updates['cal_readerModule'] = $result->moduleMap[$oldReaderModuleId];
|
||||
}
|
||||
}
|
||||
|
||||
if ($updates !== []) {
|
||||
$updates['tstamp'] = time();
|
||||
$this->connection->update('tl_module', $updates, ['id' => $newModuleId]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->rewriteNewsItemReferences($result);
|
||||
}
|
||||
|
||||
private function rewriteNewsItemReferences(DummyCopyResult $result): void
|
||||
{
|
||||
if ($result->newsItemMap === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($result->newsItemMap as $oldNewsId => $newNewsId) {
|
||||
$sourceRow = $this->fetchRow('tl_news', $oldNewsId);
|
||||
|
||||
if ($sourceRow === null || !array_key_exists('related', $sourceRow)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$related = StringUtil::deserialize((string) ($sourceRow['related'] ?? ''), true);
|
||||
|
||||
if ($related === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mappedRelated = [];
|
||||
|
||||
foreach ($related as $relatedIdValue) {
|
||||
$relatedId = (int) $relatedIdValue;
|
||||
|
||||
if ($relatedId < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mappedRelated[] = (string) ($result->newsItemMap[$relatedId] ?? $relatedId);
|
||||
}
|
||||
|
||||
$this->connection->update(
|
||||
'tl_news',
|
||||
[
|
||||
'related' => StringUtil::serialize($mappedRelated),
|
||||
'tstamp' => time(),
|
||||
],
|
||||
['id' => $newNewsId]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,7 +451,8 @@ final class DummyCopier
|
||||
$newsRow['jumpTo'] = $result->pageMap[(int) $newsRow['jumpTo']];
|
||||
}
|
||||
|
||||
$this->insertRow('tl_news', $newsRow);
|
||||
$newNewsId = $this->insertRow('tl_news', $newsRow);
|
||||
$result->newsItemMap[(int) $newsId] = $newNewsId;
|
||||
$result->copiedNewsItems++;
|
||||
}
|
||||
}
|
||||
@@ -456,7 +517,8 @@ final class DummyCopier
|
||||
$eventRow['jumpTo'] = $result->pageMap[(int) $eventRow['jumpTo']];
|
||||
}
|
||||
|
||||
$this->insertRow('tl_calendar_events', $eventRow);
|
||||
$newEventId = $this->insertRow('tl_calendar_events', $eventRow);
|
||||
$result->eventMap[(int) $eventId] = $newEventId;
|
||||
$result->copiedEvents++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,12 @@ final class DummyCopyResult
|
||||
/** @var array<int,int> */
|
||||
public array $calendarMap = [];
|
||||
|
||||
/** @var array<int,int> */
|
||||
public array $newsItemMap = [];
|
||||
|
||||
/** @var array<int,int> */
|
||||
public array $eventMap = [];
|
||||
|
||||
/** @var array<string> */
|
||||
public array $notes = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user