Plugin Directory

Changeset 3639213


Ignore:
Timestamp:
08/09/2026 09:45:25 AM (3 months ago)
Author:
fizteq
Message:

Release 1.0.14: report the real PHP error level so warnings and deprecations are ranked properly; enforce reported levels inside the handler; retina banner

Location:
fizteq-pulse
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • fizteq-pulse/trunk/includes/monitors/class-monitor-errors.php

    r3512777 r3639213  
    2525    private $max_frames = 50;
    2626
     27    /**
     28     * Error levels we report, and the only ones handle_error() acts on.
     29     *
     30     * This is deliberately both the set_error_handler() mask and an explicit
     31     * check inside the handler. The mask alone only governs what PHP itself
     32     * dispatches: when another plugin or theme registers its own handler and
     33     * chains to the previous one with call_user_func, our handler is invoked
     34     * directly for every level and the mask is bypassed entirely. That is how
     35     * deprecations reached the dashboard before this — arriving as E_UNKNOWN,
     36     * from a site whose theme chains handlers, while the mask said E_USER_ERROR.
     37     *
     38     * We want them, but on purpose rather than by accident: a deprecation is how
     39     * the site owner learns their theme breaks on the next PHP release. The
     40     * dashboard classifies notices and deprecations as info, so they land in a
     41     * daily summary rather than an immediate alert.
     42     *
     43     * E_STRICT is omitted: it has been deprecated as a constant since PHP 8.4
     44     * and referencing it would have this plugin emit the very thing it reports.
     45     *
     46     * @return int
     47     */
     48    private function reported_levels()
     49    {
     50        return E_ERROR | E_WARNING | E_PARSE | E_NOTICE
     51            | E_CORE_ERROR | E_CORE_WARNING
     52            | E_COMPILE_ERROR | E_COMPILE_WARNING
     53            | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE
     54            | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
     55    }
     56
    2757    public static function get_key()
    2858    {
    … …  
    3868        $this->previous_exception_handler = set_exception_handler([$this, 'handle_exception']);
    3969        // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler -- Error tracking is the plugin's core purpose.
    40         $this->previous_error_handler = set_error_handler([$this, 'handle_error'], E_USER_ERROR);
     70        $this->previous_error_handler = set_error_handler([$this, 'handle_error'], $this->reported_levels());
    4171        register_shutdown_function([$this, 'handle_shutdown']);
    4272    }
    … …  
    70100
    71101    /**
    72      * Handle PHP errors (E_USER_ERROR).
     102     * Handle a PHP error.
     103     *
     104     * The errno check is not redundant with the set_error_handler() mask — see
     105     * reported_levels(). A chained handler calling us directly bypasses the mask,
     106     * so without this the plugin reports whatever that handler happened to
     107     * receive, including levels it was never configured for.
     108     *
     109     * Also honours the site's own error_reporting() level, so a host that has
     110     * switched deprecations off is not overridden by us.
    73111     *
    74112     * @param int $errno
    … …  
    80118    public function handle_error($errno, $errstr, $errfile, $errline)
    81119    {
     120        $reportable = ($errno & $this->reported_levels()) && (error_reporting() & $errno);
     121
     122        if (! $reportable) {
     123            if ($this->previous_error_handler !== null) {
     124                return call_user_func($this->previous_error_handler, $errno, $errstr, $errfile, $errline);
     125            }
     126
     127            return false;
     128        }
     129
    82130        try {
    83131            if (! $this->is_handling && $this->errors_reported < $this->max_errors_per_request) {
    … …  
    234282    private function error_type_string($type)
    235283    {
     284        /**
     285         * The dashboard maps these names to a severity, so an unmapped level
     286         * costs more than a cosmetic label: everything used to collapse to
     287         * E_UNKNOWN, which is classified critical, and a theme's deprecations
     288         * therefore alerted like fatals.
     289         */
    236290        $map = [
    237291            E_ERROR => 'E_ERROR',
     292            E_WARNING => 'E_WARNING',
    238293            E_PARSE => 'E_PARSE',
     294            E_NOTICE => 'E_NOTICE',
    239295            E_CORE_ERROR => 'E_CORE_ERROR',
     296            E_CORE_WARNING => 'E_CORE_WARNING',
    240297            E_COMPILE_ERROR => 'E_COMPILE_ERROR',
     298            E_COMPILE_WARNING => 'E_COMPILE_WARNING',
    241299            E_USER_ERROR => 'E_USER_ERROR',
     300            E_USER_WARNING => 'E_USER_WARNING',
     301            E_USER_NOTICE => 'E_USER_NOTICE',
     302            E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
     303            E_DEPRECATED => 'E_DEPRECATED',
     304            E_USER_DEPRECATED => 'E_USER_DEPRECATED',
    242305        ];
    243306
  • fizteq-pulse/trunk/readme.txt

    r3636815 r3639213  
    44Requires at least: 5.9
    55Tested up to: 7.0
    6 Stable tag: 1.0.13
     6Stable tag: 1.0.14
    77Requires PHP: 7.4
    88License: GPLv2 or later
    … …  
    157157== Changelog ==
    158158
     159= 1.0.14 =
     160* New: PHP warnings, notices and deprecations are now reported with their actual error level, so the dashboard can rank them properly — deprecations and notices appear in your daily summary instead of alerting like a fatal error
     161* Fix: the error levels the plugin reports are now enforced inside the handler as well as declared. A theme or plugin that installs its own error handler and chains to ours could previously feed us levels we were never configured to collect
     162* The site's own error_reporting() level is now respected, so a host that has switched deprecation notices off is no longer overridden
     163
    159164= 1.0.13 =
    160165* Fix: sites updating from an earlier version now report their plugin and theme inventory straight away, instead of waiting for the next daily check
  • fizteq-pulse/trunk/wppulse.php

    r3636815 r3639213  
    44 * Plugin URI: https://wp-pulse.app
    55 * Description: Error tracking and site health monitoring for WordPress agencies. Reports errors, plugin changes, and health data to your WPPulse dashboard.
    6  * Version: 1.0.13
     6 * Version: 1.0.14
    77 * Author: FizteQ
    88 * Author URI: https://fizteq.com
    … …  
    2525}
    2626
    27 define('WPPULSE_VERSION', '1.0.13');
     27define('WPPULSE_VERSION', '1.0.14');
    2828define('WPPULSE_PLUGIN_FILE', __FILE__);
    2929define('WPPULSE_PLUGIN_DIR', plugin_dir_path(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.