This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Insert donor comment to donation. |
||
4 | * |
||
5 | * @since 2.2.0 |
||
6 | * |
||
7 | * @param int $donation_id |
||
8 | * @param array $donation_data |
||
9 | * |
||
10 | */ |
||
11 | function __give_insert_donor_donation_comment( $donation_id, $donation_data ) { |
||
12 | $is_anonymous_donation = isset( $_POST['give_anonymous_donation'] ) |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
13 | ? absint( $_POST['give_anonymous_donation'] ) |
||
0 ignored issues
–
show
|
|||
14 | : 0; |
||
15 | |||
16 | if ( ! empty( $_POST['give_comment'] ) ) { |
||
17 | $comment_meta = array( 'author_email' => $donation_data['user_info']['email'] ); |
||
18 | |||
19 | if( ! give_has_upgrade_completed('v230_move_donation_note' ) ) { |
||
0 ignored issues
–
show
|
|||
20 | // Backward compatibility. |
||
21 | $comment_meta = array( 'comment_author_email' => $donation_data['user_info']['email'] ); |
||
22 | } |
||
23 | |||
24 | $comment_id = give_insert_donor_donation_comment( |
||
0 ignored issues
–
show
$comment_id is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
25 | $donation_id, |
||
26 | $donation_data['user_info']['donor_id'], |
||
27 | trim( $_POST['give_comment'] ), // We are sanitizing comment in Give_comment:add |
||
0 ignored issues
–
show
|
|||
28 | $comment_meta |
||
29 | ); |
||
30 | } |
||
31 | |||
32 | give_update_meta( $donation_id, '_give_anonymous_donation', $is_anonymous_donation ); |
||
33 | } |
||
34 | |||
35 | add_action( 'give_insert_payment', '__give_insert_donor_donation_comment', 10, 2 ); |
||
36 | |||
37 | |||
38 | /** |
||
39 | * Validate donor comment |
||
40 | * |
||
41 | * @since 2.2.0 |
||
42 | */ |
||
43 | function __give_validate_donor_comment() { |
||
44 | // Check wp_check_comment_data_max_lengths for comment length validation. |
||
45 | if ( ! empty( $_POST['give_comment'] ) ) { |
||
46 | $max_lengths = wp_get_comment_fields_max_lengths(); |
||
47 | $comment = give_clean( $_POST['give_comment'] ); |
||
0 ignored issues
–
show
|
|||
48 | |||
49 | if ( mb_strlen( $comment, '8bit' ) > $max_lengths['comment_content'] ) { |
||
50 | give_set_error( 'comment_content_column_length', __( 'Your comment is too long.', 'give' ) ); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | add_action( 'give_checkout_error_checks', '__give_validate_donor_comment', 10, 1 ); |
||
55 | |||
56 | |||
57 | /** |
||
58 | * Update donor comment status when donation status update |
||
59 | * |
||
60 | * @since 2.2.0 |
||
61 | * |
||
62 | * @param $donation_id |
||
63 | * @param $status |
||
64 | */ |
||
65 | function __give_update_donor_donation_comment_status( $donation_id, $status ) { |
||
66 | $approve = absint( 'publish' === $status ); |
||
67 | |||
68 | /* @var WP_Comment $note */ |
||
69 | $donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) ); |
||
70 | |||
71 | if( $donor_comment instanceof WP_Comment ) { |
||
0 ignored issues
–
show
The class
WP_Comment does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
72 | wp_set_comment_status( $donor_comment->comment_ID, (string) $approve ); |
||
73 | } |
||
74 | } |
||
75 | |||
76 | add_action( 'give_update_payment_status', '__give_update_donor_donation_comment_status', 10, 2 ); |
||
77 | |||
78 | /** |
||
79 | * Remove donor comment when donation delete |
||
80 | * |
||
81 | * @since 2.2.0 |
||
82 | * |
||
83 | * @param $donation_id |
||
84 | */ |
||
85 | function __give_remove_donor_donation_comment( $donation_id ) { |
||
86 | /* @var WP_Comment $note */ |
||
87 | $donor_comment = give_get_donor_donation_comment( $donation_id, give_get_payment_donor_id( $donation_id ) ); |
||
88 | |||
89 | if( $donor_comment instanceof WP_Comment ) { |
||
0 ignored issues
–
show
The class
WP_Comment does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
90 | wp_delete_comment( $donor_comment->comment_ID ); |
||
91 | } |
||
92 | } |
||
93 | |||
94 | add_action( 'give_payment_deleted', '__give_remove_donor_donation_comment', 10 ); |
||
95 |