Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#32320 new defect (bug)

WordPress Importer: WXR_Parser_Regex adds newlines to import data, breaking serialized post meta.

Reported by: justinbusa's profile justinbusa Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Import Keywords:
Focuses: administration Cc:

Description

Original ticket: https://plugins.trac.wordpress.org/ticket/2317

Our plugin stores a fair amount of serialized data in post meta fields. When using the importer, the WXR_Parser_Regex parser loops through 8192 bytes of the import file at a time, appending a newline to the import data at the end of each loop. When a newline is inserted in the middle of our post meta, it breaks when the time comes to unserialize in the import process, leaving our users with a blank post meta field.

The offending code can be seen starting at line 459 of parsers.php...

if ( $in_post ) {
	$post .= $importline . "\n";
}

Is that newline necessary? I have verified that removing it solves the problem and imports the serialized data correctly.

@duck_ has suggested removing rtrim() and the new line which I will submit as a patch.

Attachments (1)

nonewline.diff (665 bytes) - added by justinbusa 9 years ago.
Patch without rtrim() and the newline.

Download all attachments as: .zip

Change History (3)

#1 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to WordPress.org

@justinbusa
9 years ago

Patch without rtrim() and the newline.

#2 @justinbusa
9 years ago

I just uploaded a patch without rtrim() and the newline. I tested it under several import scenarios and the issue appears to be fixed.

Note: See TracTickets for help on using tickets.