@@ -52,17 +52,17 @@ public static function errorLog(
5252 $ output ["data " ] = "data could not be JSON encoded: " . $ e ->getMessage ();
5353 }
5454 }
55- $ output ["REMOTE_USER " ] = $ _SERVER ["REMOTE_USER " ] ?? null ;
56- $ output ["REMOTE_ADDR " ] = $ _SERVER ["REMOTE_ADDR " ] ?? null ;
57- if (!is_null ($ errorid )) {
58- $ output ["errorid " ] = $ errorid ;
59- }
6055 if (!is_null ($ error )) {
6156 $ output ["error " ] = self ::throwableToArray ($ error );
6257 } else {
6358 // newlines are bad for error log, but getTrace() is too verbose
6459 $ output ["trace " ] = explode ("\n" , (new \Exception ())->getTraceAsString ());
6560 }
61+ $ output ["REMOTE_USER " ] = $ _SERVER ["REMOTE_USER " ] ?? null ;
62+ $ output ["REMOTE_ADDR " ] = $ _SERVER ["REMOTE_ADDR " ] ?? null ;
63+ if (!is_null ($ errorid )) {
64+ $ output ["errorid " ] = $ errorid ;
65+ }
6666 error_log ("$ title: " . \jsonEncode ($ output ));
6767 }
6868
@@ -132,6 +132,11 @@ public static function internalServerError(
132132 $ errorid = uniqid ();
133133 self ::errorToUser ("An internal server error has occurred. " , 500 , $ errorid );
134134 self ::errorLog ("internal server error " , $ message , $ errorid , $ error , $ data );
135+ if (!is_null ($ error ) && ini_get ("display_errors " ) && ini_get ("html_errors " )) {
136+ echo "<table> " ;
137+ echo $ error ->xdebug_message ;
138+ echo "</table> " ;
139+ }
135140 self ::die ($ message );
136141 }
137142
@@ -140,13 +145,20 @@ public static function exceptionHandler(\Throwable $e): void
140145 {
141146 ini_set ("log_errors " , true ); // in case something goes wrong and error is not logged
142147 self ::internalServerError ("An internal server error has occurred. " , error: $ e );
143- ini_set ("log_errors " , false ); // error logged successfully
144148 }
145149
146- public static function getPostData (...$ keys ): mixed
150+ public static function errorHandler (int $ severity , string $ message , string $ file , int $ line )
151+ {
152+ if (str_contains ($ message , "Undefined array key " )) {
153+ throw new ArrayKeyException ($ message );
154+ }
155+ return false ;
156+ }
157+
158+ public static function getPostData (string $ key ): mixed
147159 {
148160 try {
149- return \arrayGet ( $ _POST , ... $ keys ) ;
161+ return $ _POST [ $ key ] ;
150162 } catch (ArrayKeyException $ e ) {
151163 self ::badRequest ('failed to get $_POST data ' , $ e , [
152164 '$_POST ' => $ _POST ,
@@ -160,7 +172,7 @@ public static function getUploadedFileContents(
160172 string $ encoding = "UTF-8 " ,
161173 ): string {
162174 try {
163- $ tmpfile_path = \arrayGet ( $ _FILES , $ filename, "tmp_name " ) ;
175+ $ tmpfile_path = $ _FILES [ $ filename][ "tmp_name " ] ;
164176 } catch (ArrayKeyException $ e ) {
165177 self ::badRequest ("no such uploaded file " , $ e , [
166178 '$_FILES ' => $ _FILES ,
0 commit comments