|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75323 auto_prepend_file doesn't work with other functions
Submitted: 2017-10-05 21:19 UTC Modified: 2017-11-05 04:22 UTC
From: toolscom at hotmail dot com Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 7.1.10 OS: Windows 2012
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: toolscom at hotmail dot com
New email:
PHP Version: OS:


 [2017-10-05 21:19 UTC] toolscom at hotmail dot com
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

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;


     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);



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-09 08:49 UTC]
-Status: Open +Status: Feedback
 [2017-10-09 08:49 UTC]
Thanks for the report. Could you please clarify, what exactly is incorrect? Fe i use an index.php containing "$x = 1/0;" and set your code with a small modification to write into a file as auto_prepend_file in .user.ini. It creates a log file where i see

'Division by zero' 'E:\local_programs\nginx\html\bug75323\index.php' '5' '2' {"_GET":[],"_POST":[],"_COOKIE":[],"_FILES":[]}

which all seems correct.

 [2017-11-05 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 22:01:30 2024 UTC