Last active
May 27, 2021 16:48
-
-
Save rlorenzo/1c58e770640f73473dcc57a3de477982 to your computer and use it in GitHub Desktop.
Bug example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function icv_createVoteEvent($data) { | |
global $wpdb; | |
if (icv_insertVoteEvent($data)) { | |
icv_sendVoteOpenedEmail($wpdb->insert_id); | |
return true; | |
} | |
return false; | |
} | |
function icv_insertVoteEvent($data) { | |
global $wpdb; | |
$tbl_vote_event = $wpdb->prefix . 'icv_vote_event'; | |
$tbl_sub_vote_event = $wpdb->prefix . 'icv_sub_vote_event'; | |
$wpdb->query("START TRANSACTION"); | |
$result = $wpdb->insert($tbl_vote_event, array('opened_by_user_id' => get_current_user_id(), | |
'date_created' => gmdate('Y-m-d H:i:s'), 'company' => $data->company, 'vote_recording_link' => ($data->voteRecordingLink ? $data->voteRecordingLink : NULL), | |
'mgmt_presentation_link' => ($data->managementPresentationLink ? $data->managementPresentationLink : NULL), | |
'company_checklist' => $data->checklist, 'stage_id' => $data->stageID, | |
'fund_group_id' => $data->fundGroupID, 'is_only_fund_partners_voting' => ($data->isFundPartnersOnly ? 1 : 0), | |
'is_rapid_vote' => ($data->isRapidVote ? 1 : 0), 'bcap_size' => ($data->bcapSize ? $data->bcapSize : NULL), | |
'round_size' => ($data->roundSize ? $data->roundSize : NULL), 'bcap_secondary_size' => ($data->bcapSecondarySize ? $data->bcapSecondarySize : NULL), | |
'total_secondary_size' => ($data->totalSecondarySize ? $data->totalSecondarySize : NULL), 'lp_coinvest_name' => ($data->lpCoinvestName ? $data->lpCoinvestName : NULL), | |
'lp_coinvest_amount' => ($data->lpCoinvestAmount ? $data->lpCoinvestAmount : NULL), 'status' => 1)); | |
if ($result) { | |
if ($data->isSubVotes) { | |
$eventID = $wpdb->insert_id; | |
foreach ($data->subVotes as $subVote) { | |
$result = $wpdb->insert($tbl_sub_vote_event, array('event_id' => $eventID, 'criteria' => $subVote)); | |
if ($result === false) { | |
$wpdb->query("ROLLBACK"); | |
return false; | |
} | |
} | |
} | |
} else { | |
$wpdb->query("ROLLBACK"); | |
return false; | |
} | |
$wpdb->query("COMMIT"); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment