Skip to content

Commit dc6c1bf

Browse files
author
epriestley
committedMay 9, 2013
Fail quietly when failing to write access log
Summary: See D5874. PhutilDeferredLog's exception on `write()`/`__destruct()` is not especially important and can come at an awkward time. Instead of throwing, just emit an error message to the log. Test Plan: Faked failed writes and saw an error message in the log instead of many terrible things everywhere. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3144 Differential Revision: https://secure.phabricator.com/D5875
1 parent 83109ff commit dc6c1bf

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed
 

‎src/infrastructure/PhabricatorAccessLog.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ public static function getLog() {
2222
// NOTE: Path may be null. We still create the log, it just won't write
2323
// anywhere.
2424

25-
$log = new PhutilDeferredLog($path, $format);
26-
$log->setData(
27-
array(
28-
'D' => date('r'),
29-
'h' => php_uname('n'),
30-
'p' => getmypid(),
31-
'e' => time(),
32-
));
25+
$log = id(new PhutilDeferredLog($path, $format))
26+
->setFailQuietly(true)
27+
->setData(
28+
array(
29+
'D' => date('r'),
30+
'h' => php_uname('n'),
31+
'p' => getmypid(),
32+
'e' => time(),
33+
));
3334

3435
self::$log = $log;
3536
}

‎support/PhabricatorStartup.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,11 @@ public static function didFatal($message) {
194194
if ($access_log) {
195195
// We may end up here before the access log is initialized, e.g. from
196196
// verifyPHP().
197-
198-
try {
199-
$access_log->setData(
200-
array(
201-
'c' => 500,
202-
));
203-
$access_log->write();
204-
} catch (Exception $ex) {
205-
$message .= "\n(Moreover, unable to write to access log.)";
206-
}
197+
$access_log->setData(
198+
array(
199+
'c' => 500,
200+
));
201+
$access_log->write();
207202
}
208203

209204
header(

0 commit comments

Comments
 (0)
Failed to load comments.