Skip to content

Commit 8e10cfe

Browse files
committed
- handle errors better from HTTP response
1 parent 4926751 commit 8e10cfe

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

eventum/misc/scm/process_cvs_commits.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// | Authors: João Prado Maia <[email protected]> |
2727
// +----------------------------------------------------------------------+
2828
//
29-
// @(#) $Id: process_cvs_commits.php 3284 2007-03-19 23:54:48Z glen $
29+
// @(#) $Id: process_cvs_commits.php 3502 2007-12-05 10:34:30Z glen $
3030

3131

3232
// URL to your Eventum installation.
@@ -77,7 +77,7 @@
7777
}
7878

7979
// get the full commit message
80-
$commit_msg = substr($input, strpos($input, 'Log Message:')+strlen('Log Message:')+1);
80+
$commit_msg = substr($input, strpos($input, 'Log Message:') + strlen('Log Message:') + 1);
8181

8282
// parse the commit message and get the first issue number we can find
8383
$pattern = "/(?:issue|bug) ?:? ?#?(\d+)/i";
@@ -110,14 +110,18 @@
110110
die("Error: Could not ping the Eventum SCM handler script.\n");
111111
} else {
112112
$msg = "GET $ping_url HTTP/1.1\r\n";
113-
$msg .= "Host: $data[host]\r\n";
113+
$msg .= "Host: {$data['host']}\r\n";
114114
$msg .= "Connection: Close\r\n\r\n";
115115
fwrite($fp, $msg);
116116
$buf = fgets($fp, 4096);
117-
list($proto, $status, $msg) = explode(' ', trim($buf), 3);
118-
if ($status != '200') {
119-
echo "Error: Could not ping the Eventum SCM handler script: HTTP status code: $status $msg\n";
120-
}
117+
if (!$buf) {
118+
echo "Error: Couldn't read response from $ping_url\n";
119+
} else {
120+
list($proto, $status, $msg) = explode(' ', trim($buf), 3);
121+
if ($status != '200') {
122+
echo "Error: Could not ping the Eventum SCM handler script: HTTP status code: $status $msg\n";
123+
}
124+
}
121125
fclose($fp);
122126
}
123127
}

0 commit comments

Comments
 (0)