Skip to content

Commit

Permalink
Init $g_display_errors with dev settings on localhost
Browse files Browse the repository at this point in the history
When the server name is localhost/127.0.0.1, we automatically set
$g_display_error to the recommended development values, i.e.

 - E_USER_ERROR   => DISPLAY_ERROR_HALT
 - E_WARNING      => DISPLAY_ERROR_HALT
 - E_ALL          => DISPLAY_ERROR_INLINE

Issue #17501
  • Loading branch information
dregad committed Aug 7, 2014
1 parent e788e93 commit ddc78c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion config_defaults_inc.php
Expand Up @@ -4084,7 +4084,8 @@
* The default settings are recommended for use in Production, and will only
* display MantisBT fatal errors, suppressing output of all other error types.
*
* Recommended config_inc.php settings for developers:
* Recommended config_inc.php settings for developers (these are automatically
* set if the server is localhost):
* $g_display_errors = array(
* E_USER_ERROR => DISPLAY_ERROR_HALT,
* E_WARNING => DISPLAY_ERROR_HALT,
Expand All @@ -4101,6 +4102,15 @@
E_USER_ERROR => DISPLAY_ERROR_HALT,
);

# Add developers defaults when server is localhost
# Note: intentionally not using SERVER_ADDR as it's not guaranteed to exist
if( strcasecmp( $_SERVER['SERVER_NAME'], 'localhost' ) == 0
|| $_SERVER['SERVER_NAME'] == '127.0.0.1'
) {
$g_display_errors[E_WARNING] = DISPLAY_ERROR_HALT;
$g_display_errors[E_ALL] = DISPLAY_ERROR_INLINE;
}

/**
* Detailed error messages
* Shows a list of variables and their values when an error is triggered.
Expand Down
7 changes: 7 additions & 0 deletions docbook/Admin_Guide/en-US/Configuration.xml
Expand Up @@ -3527,6 +3527,13 @@ $g_display_errors = array(
);
</programlisting>
</para>
<note>
<para>The system automatically sets
<emphasis>$g_display_errors</emphasis>
to the above recommended development values when
the server's name is <emphasis>localhost</emphasis>.
</para>
</note>
<para>Less intrusive settings, recommended for testing purposes:
<programlisting>
$g_display_errors = array(
Expand Down

0 comments on commit ddc78c9

Please sign in to comment.