Skip to content

Commit ac66004

Browse files
author
Joseph Lenton
committed
JosephLenton#29 added IIS support, thinner font, backgrund now fixed
* IIS support is added. When FastCGI logs an error, IIS take over the request by default, and then show it. This meant PHP Error was failing when it logged an error. Now we don't log an error if PHP Error is running (since we are just going to tell them) * background div is now fixed, to cover up anything that has outputted before the error is displayed. * The font set in a previous commit was incorrect, it's now set to the correct, thinner version.
1 parent fbd7a13 commit ac66004

File tree

1 file changed

+51
-8
lines changed

1 file changed

+51
-8
lines changed

src/php_error.php

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,16 @@ class ErrorHandler
529529
'text/html',
530530
'application/xhtml+xml'
531531
);
532+
533+
private static function isIIS() {
534+
return (
535+
$_SERVER['SERVER_SOFTWARE'] &&
536+
strpos($_SERVER['SERVER_SOFTWARE'], 'IIS/') !== false
537+
) || (
538+
$_SERVER['_FCGI_X_PIPE_'] &&
539+
strpos($_SERVER['_FCGI_X_PIPE_'], 'IISFCGI') !== false
540+
);
541+
}
532542

533543
/**
534544
* This attempts to state if this is *not* a PHP request,
@@ -2276,9 +2286,13 @@ private function logError( $message, $file, $line, $ex=null ) {
22762286
$parts = explode( "\n", $trace );
22772287
$trace = " " . join( "\n ", $parts );
22782288

2279-
error_log( "$message \n $file, $line \n$trace" );
2289+
if ( ! ErrorHandler::isIIS() ) {
2290+
error_log( "$message \n $file, $line \n$trace" );
2291+
}
22802292
} else {
2281-
error_log( "$message \n $file, $line" );
2293+
if ( ! ErrorHandler::isIIS() ) {
2294+
error_log( "$message \n $file, $line" );
2295+
}
22822296
}
22832297
}
22842298

@@ -2580,6 +2594,10 @@ private function runDisableErrors() {
25802594
error_reporting( $this->defaultErrorReportingOff );
25812595

25822596
@ini_restore( 'html_errors' );
2597+
2598+
if ( ErrorHandler::isIIS() ) {
2599+
@ini_restore( 'log_errors' );
2600+
}
25832601
}
25842602
}
25852603

@@ -2601,6 +2619,10 @@ private function runEnableErrors() {
26012619
error_reporting( $this->defaultErrorReportingOn );
26022620
@ini_set( 'html_errors', false );
26032621

2622+
if ( ErrorHandler::isIIS() ) {
2623+
@ini_set( 'log_errors', false );
2624+
}
2625+
26042626
set_error_handler(
26052627
function( $code, $message, $file, $line, $context ) use ( $self, &$catchSurpressedErrors ) {
26062628
/*
@@ -2822,7 +2844,7 @@ private function displayJSInjection() {
28222844

28232845
iframe.style.background = 'transparent';
28242846
iframe.style.opacity = 0;
2825-
iframe.style.zIndex = 100000;
2847+
iframe.style.zIndex = 100001;
28262848
iframe.style.top = 0;
28272849
iframe.style.right = 0;
28282850
iframe.style.left = 0;
@@ -3365,7 +3387,7 @@ function displayHTML( Closure $head, $body=null, $javascript=null ) {
33653387

33663388
h1,
33673389
h2 {
3368-
font-family: "Segoe UI", "Segoe WP", "Helvetica Neue", Roboto, "sans-serif";
3390+
font-family: "Segoe UI Light","Helvetica Neue",'RobotoLight',"Segoe UI","Segoe WP",sans-serif;
33693391
font-weight: 100;
33703392
}
33713393
h1 {
@@ -3384,7 +3406,17 @@ function displayHTML( Closure $head, $body=null, $javascript=null ) {
33843406
-moz-box-sizing: border-box;
33853407
box-sizing: border-box;
33863408

3387-
position: relative;
3409+
/*
3410+
* Take over the page via CSS,
3411+
* so we block anything already rendered.
3412+
*/
3413+
position: fixed;
3414+
top: 0;
3415+
left: 0;
3416+
right: 0;
3417+
bottom: 0;
3418+
3419+
z-index: 100000;
33883420

33893421
height: 100%;
33903422
overflow: auto;
@@ -3407,6 +3439,12 @@ function displayHTML( Closure $head, $body=null, $javascript=null ) {
34073439
min-height: 0;
34083440

34093441
overflow: hidden;
3442+
3443+
position: relative;
3444+
top: auto;
3445+
left: auto;
3446+
right: auto;
3447+
bottom: auto;
34103448
}
34113449

34123450
#ajax-info,
@@ -3588,21 +3626,25 @@ function displayHTML( Closure $head, $body=null, $javascript=null ) {
35883626

35893627
color: #ddd;
35903628
list-style-type: none;
3629+
35913630
/* needed for empty lines */
35923631
min-height: 20px;
35933632
padding-right: 18px;
35943633
padding-bottom: 1px;
35953634

3596-
border-radius: 2px;
3597-
3598-
-moz-box-sizing: border-box;
35993635
box-sizing: border-box;
3636+
padding-left: 166px;
3637+
3638+
border-radius: 2px;
36003639

36013640
display: inline-block;
36023641
float: left;
36033642
clear: both;
36043643

36053644
position: relative;
3645+
3646+
/* Chrome fix */
3647+
min-width: 50%;
36063648
}
36073649
.error-file-line-number {
36083650
position: absolute;
@@ -3678,6 +3720,7 @@ function displayHTML( Closure $head, $body=null, $javascript=null ) {
36783720
.error-stack-trace-line > .filename {
36793721
}
36803722
.error-stack-trace-line > .lineinfo {
3723+
width: 100%; /* fix for chrome */
36813724
padding-right:18px;
36823725
padding-left: 82px;
36833726
text-indent: -64px;

0 commit comments

Comments
 (0)