-
Hi there, I'm trying to port my Vanilla 1 board to Flarum, but I'm running into some strange behaviors. Some fields seem to be NULL when going from the temporary (PORT_) tables to the Flarum table. For example (added some line breaks for readability):
Further down, the stack trace shows the actual data being inserted:
As you can see, some fields are fine, like the dates, but others, like the discussion id, are NULL, which seems to cause the constraint violation. I was able to print the query that retrieves the data from the Vanilla1 board, and running it on the database does return the expected values: SELECT d.*,
d.LastUserID as LastCommentUserID,
d.DateCreated as DateCreated2, d.AuthUserID as AuthUserID2,
c.Body,
c.FormatType as Format
FROM VANILLA_Discussion d
LEFT JOIN VANILLA_Comment c
ON d.FirstCommentID = c.CommentID
WHERE coalesce(d.WhisperUserID, 0) = 0 and d.Active = 1; So I'm not sure whether the data is not being inserted correctly into PORT_ or if something else is happening when going from PORT_ to Flarum. Can I dump the PORT_ data somehow, or something else I could try? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Printing this query on $query = $ex->dbImport()->table('PORT_Discussion')
->select(
'*',
$ex->dbImport()->raw('CountComments as post_number_index'),
$ex->dbImport()->raw('DiscussionID as slug'),
$ex->dbImport()->raw('0 as votes'),
$ex->dbImport()->raw('0 as hotness')
);
print_r($query->get()); Sample row from above:
|
Beta Was this translation helpful? Give feedback.
-
I found the issue! public function mapData(array $row, array $map): array
{
// @todo One of those moments I wish I had a collections library in here.
foreach ($map as $src => $dest) {
foreach ($row as $columnName => $value) {
if ($columnName === $src) {
$row[$dest] = $value; // Add column with new name.
unset($row[$columnName]); // Remove old column.
}
}
}
return $row;
} When |
Beta Was this translation helpful? Give feedback.
-
I've opened a PR with a fix: #39 |
Beta Was this translation helpful? Give feedback.
I found the issue!
The problem is in
src/Storage.php
:When
$dest
and$columnName
are the same, it's unsetting a column it should keep. So both Vanilla1 and PORT_ useUserID
for the user's id column, so…