Bug #75323 [NEW]: auto_prepend_file doesn't work with other functions

From: Date: Thu, 05 Oct 2017 21:19:20 +0000
Subject: Bug #75323 [NEW]: auto_prepend_file doesn't work with other functions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211539@lists.php.net to get a copy of this message
From: toolscom at hotmail dot com Operating system: Windows 2012 PHP version: 7.1.10 Package: Unknown/Other Function Bug Type: Bug Bug description:auto_prepend_file doesn't work with other functions Description: ------------ If you use a set_error_handler() or register_shutdown_function() inside and (auto_prepend_file = "file.php") unusual behaviors such as register_shutdown_function() will not work on fatal error as well as the set_error_handler() will pass errors/warnings incorrectly to the function receiving the error. If you don't use the auto_prepend_file and place the code in say your index.php file and create an error the code will work fine [.user.ini] auto_prepend_file = "C:\IIS\Sites\site\test\log.php" Test script: --------------- function myErrorHandlerr($errno, $errstr, $errfile, $errline, $error_context) { $servername = "localhost"; $username = "root"; $password = "Tashia123"; $dbname = "log"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // prepare and bind $stmt = $conn->prepare("INSERT INTO error_logs (error) VALUES (?)"); $errorssssss = $errstr.$errfile. $errline.$errno . json_encode($error_context); // $stmt->bind_param("s", $errorssssss); // echo $errline; $stmt->execute(); $stmt->close(); $conn->close(); } function shutdownHandler() //will be called when php script ends. { $lasterror = error_get_last(); switch ($lasterror['type']) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_PARSE: $error = "[SHUTDOWN] lvl:" . $lasterror['type'] . " | msg:" . $lasterror['message'] . " | file:" . $lasterror['file'] . " | ln:" . $lasterror['line']; myErrorHandlerr($error, "fatal",'','',''); } } // Set user-defined error handler function set_error_handler("myErrorHandlerr", E_ALL | E_STRICT); register_shutdown_function("shutdownHandler"); -- Edit bug report at https://bugs.php.net/bug.php?id=75323&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75323&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75323&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75323&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75323&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75323&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75323&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75323&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75323&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75323&r=support Expected behavior: https://bugs.php.net/fix.php?id=75323&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75323&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75323&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75323&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75323&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75323&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75323&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75323&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75323&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75323&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75323&r=mysqlcfg

« previous php.bugs (#211539) next »