Plugin Directory

Opened 3 years ago

Closed 3 years ago

#2317 closed defect (duplicate)

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

Reported by: justinbusa Owned by:
Priority: high Severity: major
Plugin: not-listed Keywords:


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.

Change History (7)

comment:1 @ryan3 years ago

@duck_ I don't remember why that line is in there. Can you provide some institutional memory?

comment:3 @justinbusa3 years ago

@duck_ Let me know if you think that can be removed and I can provide a patch. Looking at the code I can't tell if there is a reason for it.

comment:4 @duck_3 years ago

Looking at the changeset Ryan linked above it looks like its a direct port of the old code, see line 166 (red) of wordpress-importer/trunk/wordpress-importer.php in the diff.

I don't think it can just be removed due to the call to rtrim() on line 418. It looks like the rtrim() was ported over as well, so it may be worth looking into its history and removing that AND the appended new line if possible. I'm thinking that not messing with spacing could be the best approach.

comment:5 @SergeyBiryukov3 years ago

@justinbusa, could you create a ticket on https://core.trac.wordpress.org/, under the Import component? We track importer plugin issues there.

comment:6 @justinbusa3 years ago

@SergeyBiryukov Done! Work is a bit crazy right now but I plan on submitting a patch soon. Thanks for the help everyone!

comment:7 @SergeyBiryukov3 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Thanks, closing as a duplicate of https://core.trac.wordpress.org/ticket/32320.

Note: See TracTickets for help on using tickets.