set_web_service_connection_info($matches); require $migration->web_service_connection_info['filename']; $mig = new $migration->web_service_connection_info['class']; error_log('Building in-memory data_list for speed-up '.time()); $data_list = array('boost_users'=>true, 'boost_courses'=>true, 'boost_sessions'=>true); /** * Build an array of in-memory database data to reduce time spent querying */ if (count($data_list['users'])<1) { MigrationCustom::fill_data_list($data_list); } error_log('Built in-memory data_list for speed-up '.time()); // Counter for transactions found and dealt with $count_transactions = 0; /** * Check each branch for transactions to execute (and execute them) */ $branches = $migration->get_branches(); foreach ($branches as $id => $branch) { $response = ''; $branch_id = $branch['branch_id']; if ($mode == 'process') { //Load transactions saved before $params = array('branch_id' => $branch_id, 'number_of_transactions' => $num_trans); $migration->get_transactions_from_webservice($params); $count_transactions += $migration->execute_transactions($params); } else { //if mode==fix error_log('Fixing transactions'); $params = array('branch_id' => $branch_id, 'number_of_transactions' => $num_trans); $migration->execute_transactions($params); } } /** * Free the PID file used as semaphore */ if (is_file($pidfile)) { $opid = trim(file_get_contents($pidfile)); if (intval($opid) == intval($pid)) { $res = @exec('rm '.$pidfile); if ($res === false) { error_log('Could not delete PID file'); die('Could not delete PID file'); } error_log('PID file deleted for PID '.$pid); error_log(str_repeat('=',40)); } else { error_log('PID file is not of current process. Not deleting.'); die('PID file is not of current process. Not deleting.'."\n"); } } $cron_total = time() - $cron_start; error_log('Total time taken for transaction run: '.$cron_total.'s for '.$count_transactions.' transactions');