Ticket #8019 (assigned defect (bug))

Opened 13 months ago

Last modified 2 months ago

WXR import incorrectly handles comment ID's, Results in threading being lost

Reported by: DD32 Owned by: joostdevalk
Priority: high Milestone: 2.9
Component: Import Version: 2.7
Severity: major Keywords: needs-patch
Cc:

Description

The Export'd WXR files & Import process contains the original Comment ID, and Comment Parent ID allready. However, Upon import, the Comment ID's are re-assigned, however the parent ID's are not.

The result is that the comment threading is lost entirely.

Eg: Previously comment 1234 was in reply to comment 1222, however, comment 1222 is now comment 22, but comment 1234 still has '1222' as its parent_id.

2 options are possible:

  • Remapping the comment parent ID's
  • Preserving the comment ID's

The only issue i see with preserving the comment ID's is that importing into another blog with comments allready could cause conflicts, which would require remapping of some comment ID's regardless.

Attachments

wordpress.php.diff (3.5 KB) - added by joostdevalk 6 months ago.
Patch
testwxr.xml (9.7 KB) - added by joostdevalk 6 months ago.
WXR File I used to test the patch

Change History

  Changed 12 months ago by ryan

[9100] is how we fixed this for posts.

  Changed 12 months ago by ryan

  • keywords early added
  • milestone changed from 2.7 to 2.8

Too big a job for 2.7. Let's shoot for early 2.8 with a possible backport to a 2.7 dot release.

  Changed 7 months ago by janeforshort

  • milestone changed from 2.8 to Future Release

Punting due to feature freeze. Reconsider with next release.

  Changed 6 months ago by tott

I am currently testing a patch that preserves the comment_IDs where possible. This solves most of the issues. I will attach the patch after some more testing.

  Changed 6 months ago by lloydbudd

  • owner set to tott
  • priority changed from normal to high
  • status changed from new to assigned
  • milestone changed from Future Release to 2.9

With threaded commenting in core with 2.7, now more threading in the wild. Raising priority. Depending on 2.8 release status and nature of the solution should consider getting in 2.8 .

Changed 6 months ago by joostdevalk

Patch

  Changed 6 months ago by joostdevalk

  • keywords has-patch added; needs-patch early removed
  • owner changed from tott to joostdevalk

Changed 6 months ago by joostdevalk

WXR File I used to test the patch

  Changed 6 months ago by joostdevalk

  • keywords needs-testing added

  Changed 6 months ago by joostdevalk

  • milestone changed from 2.9 to 2.8

I'd like to get this in in 2.8, I think it's a pretty simple and solid patch which solves a major annoyance...

  Changed 6 months ago by Denis-de-Bernardy

  • keywords commit added

IRC discussion for reference:

[09:30] <jdevalk> basically threw all comments into an array, sort them by id, remapped the wxr id's to the new id's and attach the correct parent
[09:31] <jdevalk> also working on a plugin that let's you import wxr files that are on the server, so you're not capped by HTTP upload restraints
[09:31] <ddebernardy> I take it you tested before/after with your data already, no?
[09:31] <jdevalk> yes.
[09:33] <ddebernardy> patch's logic seems correct
[09:33] <jdevalk> yeah it's not too hard
[09:34] <ddebernardy> an alternative method, which might be more robust, could be re-key the comments array based on parents
[09:34] <ddebernardy> array ( comment_parent => comments )
[09:34] <ddebernardy> and then do a double foreach loop
[09:34] <jdevalk> not sure i follow? :)
[09:35] <ddebernardy> well, it would cover the case where a weirdo plays with his database
[09:35] <ddebernardy> and ends up with comment IDs in an order than hasn't much to do with the comments date or hierarchy
[09:35] <ddebernardy> but it's such an edge case that we can ignore it imo
[09:36] <jdevalk> yeah i think so too

Safe to commit imo.

  Changed 6 months ago by Denis-de-Bernardy

  • milestone changed from 2.8 to 2.9

can wait until 2.9

  Changed 6 months ago by Denis-de-Bernardy

  • milestone changed from 2.9 to 2.8

unless someone wants to try it...

  Changed 6 months ago by Denis-de-Bernardy

  • keywords early added
  • milestone changed from 2.8 to 2.9

per discussion in IRC

  Changed 5 months ago by Denis-de-Bernardy

  • keywords needs-patch added; has-patch needs-testing commit early removed

let's give the double array approach a try, just in case.

http://core.trac.wordpress.org/ticket/8019#comment:9

follow-up: ↓ 15   Changed 3 months ago by ocean90

I want to test the patch but I get an error on WP and WPMU 2.8.4:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in .../wordpress.php on line 529

Is there something new? Would be nice if the bug can be fixed.

in reply to: ↑ 14   Changed 3 months ago by ocean90

Sorry, my mistake.

It works now. Thanks.

follow-up: ↓ 17   Changed 2 months ago by michaelh

Assuming the correct advice was provided, this fix didn't solve the problem according to this Forum thread:

 http://wordpress.org/support/topic/312843

in reply to: ↑ 16   Changed 2 months ago by michaelh

Replying to michaelh:

Assuming the correct advice was provided, this fix didn't solve the problem

Retracting that statement as the patch wordpress.php.diff does in fact fix the threaded comment problem at 2.8.4:

 http://wordpress.org/support/topic/312843?replies=17#post-1225031

Note: See TracTickets for help on using tickets.