Skip to content

Commit 7be677d

Browse files
Fix data unserialize error Codeinwp/visualizer-pro#316
1 parent 977d0bf commit 7be677d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

classes/Visualizer/Module.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,17 @@ public static final function get_features_for_license( $plan ) {
740740
*/
741741
public static function get_chart_data( $chart, $type, $run_filter = true ) {
742742
// 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 );
744754
$altered = array();
745755
if ( ! empty( $data ) ) {
746756
foreach ( $data as $index => $array ) {

0 commit comments

Comments
 (0)