From 4e46d362a4fce130299fd0c1a7890a4760c113e2 Mon Sep 17 00:00:00 2001 From: Louis-Arnaud Catoire Date: Tue, 25 Aug 2026 22:04:16 +0200 Subject: [PATCH] errorfunc: document the error handler stack set_error_handler() saves the handler that was active until then on an internal stack and installs the new one in its place; restore_error_handler() pops the saved one back, together with the error_levels mask it was registered with. Neither page said so, which invites restoring the previous handler by passing the return value of set_error_handler() back to it. That grows the stack instead of shrinking it, and resets error_levels to E_ALL. Adds a caution against that pattern and an example calling the previous handler from the new one. The seealso simplelists are unwrapped from their para, matching the exception handler pages. --- .../functions/restore-error-handler.xml | 32 +++--- .../errorfunc/functions/set-error-handler.xml | 99 +++++++++++++++---- 2 files changed, 100 insertions(+), 31 deletions(-) diff --git a/reference/errorfunc/functions/restore-error-handler.xml b/reference/errorfunc/functions/restore-error-handler.xml index 31cbc6c532bb..a374b5de3820 100644 --- a/reference/errorfunc/functions/restore-error-handler.xml +++ b/reference/errorfunc/functions/restore-error-handler.xml @@ -12,11 +12,17 @@ truerestore_error_handler - - Used after changing the error handler function using - set_error_handler, to revert to the previous error - handler (which could be the built-in or a user defined function). - + + Pops the error handler that was active before the most recent call to + set_error_handler off the internal stack of error + handlers and makes it active again, together with the + error_levels mask it was registered with. + The restored handler could be the built-in or a user defined function. + + + Calling this function more often than set_error_handler + leaves the built-in error handler active; no error is raised. + @@ -67,15 +73,13 @@ Invalid serialized value. &reftitle.seealso; - - - error_reporting - set_error_handler - get_error_handler - restore_exception_handler - trigger_error - - + + error_reporting + set_error_handler + get_error_handler + restore_exception_handler + trigger_error +