function make_body($description) { return empty($description) ? 'None' : translate_markup($description); }
} else { // Error $error = print_r($resp, 1); echo "Failed to convert a ticket #{$row['id']}: {$error}\n"; } } // Serialize to restore in future file_put_contents($save_tickets, serialize($tickets)); } if (!$skip_comments) { // Export all comments $limit = $comments_limit > 0 ? "LIMIT {$comments_offset}, {$comments_limit}" : ''; $res = $trac_db->query("SELECT * FROM `ticket_change` where `field` = 'comment' AND `newvalue` != '' ORDER BY `ticket`, `time` {$limit}"); foreach ($res->fetchAll() as $row) { $text = strtolower($row['author']) == strtolower($username) ? $row['newvalue'] : '**Author: ' . $row['author'] . "**\n" . $row['newvalue']; $resp = github_add_comment($tickets[$row['ticket']], translate_markup($text)); if (isset($resp['url'])) { // OK echo "Added comment {$resp['url']}\n"; } else { // Error $error = print_r($resp, 1); echo "Failed to add a comment: {$error}\n"; } } } echo "Done whatever possible, sorry if not.\n"; function github_post($url, $json, $patch = false) { global $username, $password; $ch = curl_init();