| @@ -739,18 +739,30 @@ | ||
| 739 | 739 | * Gets the chart content after common manipulations. |
| 740 | 740 | */ |
| 741 | 741 | public static function get_chart_data( $chart, $type, $run_filter = true ) { |
| 742 | 742 | // change HTML entities |
| 743 | - $data = unserialize( html_entity_decode( htmlentities( $chart->post_content ) ) ); | |
| 743 | + $post_content = html_entity_decode( htmlentities( $chart->post_content ) ); | |
| 744 | + $post_content = preg_replace_callback( | |
| 745 | + '!s:(\d+):"(.*?)";!s', | |
| 746 | + function ( $matches ) { | |
| 747 | + if ( isset( $matches[2] ) ) { | |
| 748 | + return 's:' . strlen( $matches[2] ) . ':"' . $matches[2] . '";'; | |
| 749 | + } | |
| 750 | + }, | |
| 751 | + $post_content | |
| 752 | + ); | |
| 753 | + $data = unserialize( $post_content ); | |
| 744 | 754 | $altered = array(); |
| 745 | - foreach ( $data as $index => $array ) { | |
| 746 | - if ( ! is_array( $index ) && is_array( $array ) ) { | |
| 747 | - foreach ( $array as &$datum ) { | |
| 748 | - if ( is_string( $datum ) ) { | |
| 749 | - $datum = stripslashes( $datum ); | |
| 755 | + if ( ! empty( $data ) ) { | |
| 756 | + foreach ( $data as $index => $array ) { | |
| 757 | + if ( ! is_array( $index ) && is_array( $array ) ) { | |
| 758 | + foreach ( $array as &$datum ) { | |
| 759 | + if ( is_string( $datum ) ) { | |
| 760 | + $datum = stripslashes( $datum ); | |
| 761 | + } | |
| 750 | 762 | } |
| 763 | + $altered[ $index ] = $array; | |
| 751 | 764 | } |
| 752 | - $altered[ $index ] = $array; | |
| 753 | 765 | } |
| 754 | 766 | } |
| 755 | 767 | // if something goes wrong and the end result is empty, be safe and use the original data |
| 756 | 768 | if ( empty( $altered ) ) { |