Skip to content

Commit 1b79957

Browse files
thirschthePanz
authored andcommitted
Backported display_errors-handling to sf1
1 parent 81205f6 commit 1b79957

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/config/sfApplicationConfiguration.class.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,23 @@ public function initConfiguration()
128128
}
129129

130130
// error settings
131-
ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
131+
// Based on the debug setting ($this->isDebug()), it controls if errors should be displayed
132+
// (display_errors). If the application is not in the debug mode or if it's running in a
133+
// CLI, PHPDBG, or embed server API, then errors are not displayed (display_errors is set
134+
// to 0). However, if the application is in debug mode and errors are not already logged to
135+
// the error log, then errors are displayed (display_errors is set to 1).
136+
if (
137+
!$this->isDebug()
138+
|| !in_array(PHP_SAPI, array('cli', 'phpdbg', 'embed'), true)
139+
) {
140+
ini_set('display_errors', 0);
141+
} elseif (
142+
!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN)
143+
|| ini_get('error_log')
144+
) {
145+
// CLI - display errors only if they're not already logged to STDERR
146+
ini_set('display_errors', 1);
147+
}
132148
error_reporting(sfConfig::get('sf_error_reporting'));
133149

134150
// initialize plugin configuration objects

0 commit comments

Comments
 (0)