Skip to content
Snippets Groups Projects
Commit a2477dbc authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Fixing a bug with matching the tags when migrating news

parent a2ba24c7
No related branches found
No related tags found
No related merge requests found
...@@ -174,11 +174,7 @@ class MigrateNewsCommandController extends CommandController { ...@@ -174,11 +174,7 @@ class MigrateNewsCommandController extends CommandController {
$date = new \DateTime('@' . $row['datetime']); $date = new \DateTime('@' . $row['datetime']);
$newsPage->setLastUpdated($date); $newsPage->setLastUpdated($date);
$this->setMatchingTag($row);
$matchingTag = $this->getMatchingTag($row);
if ($matchingTag && $matchingTag instanceof Tag) {
$newsPage->addTag($matchingTag);
}
/** @var File $image */ /** @var File $image */
$file = $this->getMatchingFile($row); $file = $this->getMatchingFile($row);
...@@ -253,17 +249,26 @@ class MigrateNewsCommandController extends CommandController { ...@@ -253,17 +249,26 @@ class MigrateNewsCommandController extends CommandController {
* Get the tag / category, matching the news * Get the tag / category, matching the news
* *
* @param array $row * @param array $row
* @return Object $tag
*/ */
private function getMatchingTag(array $row) { private function setMatchingTag(array $row) {
// look up the correct category id, if they have changed /** @var DatabaseConnection $db */
if (isset($this->categoryMap[(int) $row['categories']])) { $db = $GLOBALS['TYPO3_DB'];
$categoryId = $this->categoryMap[(int) $row['categories']]; // get content element from the original page
} else { $where = 'uid_foreign = ' . (int) $row['uid'];
$categoryId = (int) $row['categories'];
} /** @var \mysqli_result $result */
$result = $db->exec_SELECTquery('uid_local', 'sys_category_record_mm_news_migration', $where);
return $this->tagRepository->findByUid($categoryId); foreach ($result->fetch_row() as $mmRow) {
$values = [
'uid_local' => $this->categoryMap[(int) $mmRow[0]],
'uid_foreign' => $this->newsPagesMap[(int) $row['uid']],
'tablenames' => 'pages',
'fieldname' => 'tx_sgnews_tags'
];
$db->exec_INSERTquery('sys_category_record_mm', $values);
}
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment