Skip to content

Commit 73428b1

Browse files
Merge pull request #266 from contactashish13/issue-265
All scheduled charts are not updated if one of the scheduled charts i…
2 parents 42125d1 + 08a9aac commit 73428b1

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

classes/Visualizer/Module/Chart.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,30 @@ public function renderFlattrScript() {
438438
* @access public
439439
*/
440440
public function uploadData() {
441+
// if this is being called internally from pro and VISUALIZER_DO_NOT_DIE is set.
442+
// otherwise, assume this is a normal web request.
443+
$can_die = ! ( defined( 'VISUALIZER_DO_NOT_DIE' ) && VISUALIZER_DO_NOT_DIE );
444+
441445
// validate nonce
442-
// do not use filter_input as it does not work for phpunit test cases, use filter_var instead
443446
if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'] ) ) {
447+
if ( ! $can_die ) {
448+
return;
449+
}
444450
status_header( 403 );
445451
exit;
446452
}
453+
447454
// check chart, if chart exists
455+
// do not use filter_input as it does not work for phpunit test cases, use filter_var instead
448456
$chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : '';
449457
if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
458+
if ( ! $can_die ) {
459+
return;
460+
}
450461
status_header( 400 );
451462
exit;
452463
}
464+
453465
if ( ! isset( $_POST['vz-import-time'] ) ) {
454466
apply_filters( 'visualizer_pro_remove_schedule', $chart_id );
455467
}
@@ -468,10 +480,8 @@ public function uploadData() {
468480
}
469481
} elseif ( isset( $_FILES['local_data'] ) && $_FILES['local_data']['error'] == 0 ) {
470482
$source = new Visualizer_Source_Csv( $_FILES['local_data']['tmp_name'] );
471-
// Added by Ash/Upwork
472483
} elseif ( isset( $_POST['chart_data'] ) && strlen( $_POST['chart_data'] ) > 0 ) {
473484
$source = apply_filters( 'visualizer_pro_handle_chart_data', $_POST['chart_data'], '' );
474-
// Added by Ash/Upwork
475485
} else {
476486
$render->message = esc_html__( 'CSV file with chart data was not uploaded. Please, try again.', 'visualizer' );
477487
}
@@ -489,9 +499,10 @@ public function uploadData() {
489499
}
490500
}
491501
$render->render();
492-
if ( ! ( defined( 'VISUALIZER_DO_NOT_DIE' ) && VISUALIZER_DO_NOT_DIE ) ) {
493-
defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit();
502+
if ( ! $can_die ) {
503+
return;
494504
}
505+
defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit();
495506
}
496507

497508
/**

0 commit comments

Comments
 (0)