Skip to content

Notification ‐ Error handler

Nuno Luciano edited this page Apr 17, 2025 · 2 revisions

Since version 2.5.0

The error handling system in D3 Pico module works as a comprehensive error management solution that captures,
logs, and notifies administrators about errors. Here's how it functions:

  1. Registration Process:

    • In common_functions.php, the error handler is included and conditionally registered only when $mydirname is defined
    • This ensures the error handler only activates when the module is properly initialized
  2. Error Handler Function (from error_handler.php):

    • The pico_register_error_handler() function stores the module directory name globally and sets up the custom error handler
    • The pico_error_handler() function intercepts PHP errors and:
      • Filters errors to only handle those occurring within Pico module files
      • Logs errors to XoopsLogger if available
      • Logs to the PHP error log
      • For serious errors (E_ERROR, E_PARSE, etc.), it triggers notifications to webmasters
  3. Notification System (from notification.inc.php):

    • When serious errors occur, the pico_notify_webmasters() function is called
    • This function:
      • Identifies all webmasters and module administrators
      • Sends them private messages through the XOOPSCUBE Message system
      • Sends email notifications to administrator email addresses
      • Formats error details including file, line number, and error message

This multi-layered approach ensures that:

  • Minor errors are logged but don't interrupt site operation
  • Critical errors trigger immediate notifications to administrators
  • All errors are properly documented for troubleshooting
  • The system works within the XCL framework

The conditional registration at the end of common_functions.php is particularly important
as it prevents the error handler from being registered in contexts where the module isn't
fully initialized, which could cause additional errors.

Clone this wiki locally