Make WordPress Core

Ticket #23275: 23275.patch

File 23275.patch, 1.1 KB (added by WraithKenny, 11 years ago)
  • wordpress-importer.php

     
    703703                                                // export gets meta straight from the DB so could have a serialized string
    704704                                                if ( ! $value )
    705705                                                        $value = maybe_unserialize( $meta['value'] );
    706 
     706                                                // Occationally, line-endings break unserialize()
     707                                                if ( empty( $value ) ) // Try normalizing...
     708                                                        $value = maybe_unserialize( str_replace( array("\r\n", "\r", "\n"), "\r\n", $meta['value'] ) );
     709                                                if ( empty( $value ) ) // Adjust string length if needed
     710                                                        $value = maybe_unserialize(
     711                                                                preg_replace( // e flag deprecated in PHP 5.5.0 I think
     712                                                                        '!s:(\d+):"(.*?)";!se',
     713                                                                        "'s:'.strlen('$2').':\"$2\";'",
     714                                                                        $meta['value']
     715                                                                )
     716                                                        );
     717                                       
    707718                                                add_post_meta( $post_id, $key, $value );
    708719                                                do_action( 'import_post_meta', $post_id, $key, $value );
    709 
     720                                       
    710721                                                // if the post has a featured image, take note of this in case of remap
    711722                                                if ( '_thumbnail_id' == $key )
    712723                                                        $this->featured_images[$post_id] = (int) $value;