Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The issue is that I'm trying to import comments into drupal by creating the object array and using comment_save($comment). I'm backdating the comments I'm importing using $comment['timestamp'] but this gets overridden if the comment doesn't have a comment id, which it of course doesn't because it's a new comment.
Suggest that the timestamp is only set to 'now' iff someone hasn't manually changed it.
Here's the patch.
Comment | File | Size | Author |
---|---|---|---|
#6 | comment_import_backdate_1.patch | 770 bytes | bdragon |
#4 | comment_import_backdate_0.patch | 609 bytes | nterbogt |
comment_import_backdate.patch | 624 bytes | nterbogt | |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedseems reasonable as long as the comment form cannot be tricked, which is unlikely but should be verified.
Comment #2
drummThis might be an API change. I think it should go into Drupal 6.x before being considered for 5.x.
My only code change would be the comment. It should be an English sentence with capitalization and punctuation. And it is useful for purposes other than importing. Maybe "Default to the current time if a timestamp is not present."
Comment #3
catchpartially related to this: http://drupal.org/node/55277
Possibly there should be an "updated" column in comments for drupal 7?
Comment #4
nterbogt CreditAttribution: nterbogt commentedHere's a new patch. It's against 5.2 though because I haven't checked out 6.x.
Comment #5
nterbogt CreditAttribution: nterbogt commentedChanging this back to needing review.
Comment #6
bdragon CreditAttribution: bdragon commentedHere's a 6.x version.
Comment #7
PasqualleComment #8
nevergone CreditAttribution: nevergone commentedCorrect patch.
Comment #9
Dries CreditAttribution: Dries commented1. Patch no longer applies.
2. It would be great if we could write a test case for this.
Comment #10
Pasquallesorry, this is already fixed in D7
#253577: Allow new comment timestamp to be passed