Skip to content
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://scanfully.com
Tags: monitoring, site health, broken links, user activity, activity log
Requires at least: 6.0
Tested up to: 7.1.3
Stable tag: 1.11.0
Stable tag: 1.12.0
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Requires PHP: 7.4
Expand Down Expand Up @@ -139,10 +139,13 @@ Once connected, the plugin sends the following data to provide monitoring, diagn
* **WordPress activity:** Event details, the acting user's ID and display name, and relevant old and new setting values. Content and file edits can include changed text or code and nearby context. This includes content from draft, private, and password-protected posts.
* **WordPress user events:** User IDs, display names, and roles. Events for users with elevated permissions also include their email address. Successful logins and first application-password use for those users include IP addresses, forwarded proxy information, and browser details.
* **Failed-login summaries:** Hourly counts and details of targeted users with elevated permissions. These summaries omit IP addresses and attempted usernames.
* **PHP errors:** PHP fatal errors and warnings, with how often each happened and when. Each error includes its message, the file, line and function it came from, and a short stack trace, without function arguments. File paths are relative to the WordPress folder. Email addresses, passwords, keys, tokens, and query strings are removed from messages. Each error also includes the plugin or theme that caused it and its version, the request type, the URL path without its query string, the PHP and WordPress versions, and whether an update was running. New errors are sent within a minute, counts hourly, and a new fatal error right away.
* **WooCommerce configuration:** On connected WooCommerce sites, shop details sync even when checkout tests are off. These include the store address, WooCommerce version, product and cart/checkout URLs, shipping details, and login requirements. When checkout tests are enabled, Scanfully creates test orders. The plugin cancels test orders and deletes cancelled test orders through scheduled cleanup after seven days by default.
* **Connection changes:** When the plugin is deactivated, disconnected, or deleted, that it happened and the display name of the person who did it.
* **Sync diagnostics:** When Scanfully asks the plugin to sync, the plugin's version, when its last request to Scanfully succeeded, and the time, status, and error message of its last failed request.

PHP error monitoring is part of Scanfully's monitoring and runs while the site is connected. To catch errors raised while other plugins load, the plugin adds its must-use plugin, the file `scanfully-mu.php`, to `wp-content/mu-plugins` when that folder is writable. It removes the file when the plugin is deactivated, disconnected or deleted.

Email checks are enabled by default after connection. The plugin sends test messages through your site's mail setup to a Scanfully address. Messages include site and version details and verification identifiers. The sender defaults to your WordPress administration email. The plugin also reports the detected mail plugin or WordPress version and local send errors to the API. You can turn these checks off under Settings > Scanfully.

Read Scanfully's [terms and conditions](https://docs.scanfully.com/general/terms-and-conditions/), [privacy policy](https://docs.scanfully.com/general/privacy-policy/), and [GDPR information](https://docs.scanfully.com/general/is-scanfully-gdpr-compliant/) for service and data-handling details.
Expand All @@ -153,6 +156,12 @@ Read Scanfully's [terms and conditions](https://docs.scanfully.com/general/terms

== Changelog ==

= 1.12.0: November 14, 2026 =
* Added: PHP error monitoring: fatal errors and warnings are caught, grouped and counted, credited to the plugin, theme or WordPress core that raised them, and sent to Scanfully, which lists them per site and can alert you when a new fatal error appears
* Added: a small must-use plugin, added to wp-content/mu-plugins when that folder is writable, catches errors raised while other plugins load; it is removed when the plugin is deactivated, disconnected or deleted
* Security: email addresses, passwords, keys, tokens and query strings are removed from PHP error messages before they are sent
* Changed: the readme lists the PHP error data the plugin sends under External services

= 1.11.0: November 12, 2026 =
* Added: connecting a site goes through Scanfully's authorization server, where you pick the site and choose what Scanfully may do on it
* Added: "Change what Scanfully may do" on the settings page changes those permissions later, and cancelling keeps the current connection
Expand Down
22 changes: 19 additions & 3 deletions scanfully.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @wordpress-plugin
* Plugin Name: Scanfully
* Version: 1.11.0
* Version: 1.12.0
* Plugin URI: https://scanfully.com/wp-plugin
* Description: Scanfully is your favorite WordPress performance and health monitoring tool.
* Author: Scanfully
Expand Down Expand Up @@ -40,6 +40,11 @@
// Load Action Scheduler before plugins_loaded priority 0 so it can register its version.
require __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php';

// Catch PHP errors from here on. The must-use plugin, when it could be
// installed, already does from before any plugin loads.
require_once __DIR__ . '/src/Errors/load.php';
\Scanfully\Errors\Monitor::boot( 'plugin' );

// Declare compatibility with WooCommerce's HPOS order storage and the
// Cart/Checkout blocks. WooCommerce only accepts this inside
// before_woocommerce_init.
Expand Down Expand Up @@ -68,7 +73,7 @@ function Scanfully(): \Scanfully\Main { // phpcs:ignore WordPress.NamingConventi
function () {
// meta.
define( 'SCANFULLY_PLUGIN_FILE', __FILE__ );
define( 'SCANFULLY_VERSION', '1.11.0' );
define( 'SCANFULLY_VERSION', '1.12.0' );

// boot.
require __DIR__ . '/vendor/autoload.php';
Expand All @@ -81,6 +86,10 @@ function () {
register_activation_hook(
__FILE__,
function () {
// A connection that stayed while the plugin was inactive catches PHP
// errors again from before other plugins load.
\Scanfully\MustUse\MuPlugin::maybe_install();

// The connection was last used before the deactivation, so its first
// report needs a moment before anything calls it stale.
set_transient( 'scanfully_recently_activated', 1, 5 * MINUTE_IN_SECONDS );
Expand All @@ -90,12 +99,19 @@ function () {
// register deactivation hook.
register_deactivation_hook(
__FILE__,
function () {
function ( $network_wide = false ) {
// Tell Scanfully first, so the site's owner learns why the plugin
// stopped reporting.
if ( class_exists( '\\Scanfully\\Connect\\Controller' ) ) {
\Scanfully\Connect\Controller::report_deactivated();
}
\Scanfully\Cron\Controller::clear_scheduled_events();

// The must-use plugin serves the whole network: remove it when the
// plugin is deactivated on a single site or for the whole network.
// On a network site it does nothing while the plugin is inactive there.
if ( ! is_multisite() || $network_wide ) {
\Scanfully\MustUse\MuPlugin::remove();
}
}
);
51 changes: 51 additions & 0 deletions src/API/ErrorsRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* The PHP errors request class file.
*
* @package Scanfully
*/

namespace Scanfully\API;

use Scanfully\Main;
use Scanfully\Options\Controller as OptionsController;

/**
* Sends PHP errors to the Scanfully API.
*/
class ErrorsRequest extends Request {

/**
* Send the request to the API.
*
* @param array $data The data to send with the request.
* @param int $timeout Seconds to wait for an answer.
*
* @return int|null The HTTP status, or null when the request itself failed.
*/
public function send( array $data, int $timeout = 30 ): ?int {
return parent::do_request( '', $data, $timeout );
}

/**
* Get the url for the request.
*
* @param string $endpoint The endpoint to send the request to.
*
* @return string
*/
public function get_url( string $endpoint ): string {
return sprintf( Main::get_api_url() . '/sites/%s/errors', rawurlencode( OptionsController::get_option( 'site_id' ) ) );
}

/**
* Get the body for the request.
*
* @param array $data The data to send with the request.
*
* @return array
*/
public function get_body( array $data ): array {
return $data;
}
}
5 changes: 3 additions & 2 deletions src/API/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ abstract class Request {
*
* @param string $endpoint The endpoint to send the request to.
* @param array $data The data to send with the request.
* @param int $timeout Seconds to wait for an answer.
*
* @return int|null The HTTP status, or null when the request itself failed.
*/
public function do_request( string $endpoint, array $data ): ?int {
public function do_request( string $endpoint, array $data, int $timeout = 60 ): ?int {

// headers for the requests.
$headers = [
Expand All @@ -52,7 +53,7 @@ public function do_request( string $endpoint, array $data ): ?int {
// request arguments for the requests.
$request_args = [
'headers' => $headers,
'timeout' => 60,
'timeout' => $timeout,
'blocking' => true,
'httpversion' => '1.0',
'sslverify' => Main::get_sslverify(),
Expand Down
23 changes: 23 additions & 0 deletions src/Cron/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class Controller {
*/
public const ACTION_CHECK_MU_PLUGINS = 'scanfully_check_mu_plugins';

/**
* Hook: send the PHP errors that are waiting (recurring hourly, and
* single runs a minute after a new error and right after an update).
*/
public const ACTION_SEND_PHP_ERRORS = \Scanfully\Errors\Reporter::ACTION;

/**
* Args marker for debounced (single) site health runs, to distinguish them
* from the recurring schedule so each can be managed independently.
Expand Down Expand Up @@ -90,6 +96,7 @@ public static function setup(): void {
add_action( self::ACTION_CLEANUP_PROBE_ORDERS, [ self::class, 'cleanup_woocheckout_probe_orders' ] );
add_action( self::ACTION_SEND_FAILED_LOGINS, [ self::class, 'send_failed_logins' ] );
add_action( self::ACTION_CHECK_MU_PLUGINS, [ self::class, 'check_mu_plugins' ] );
add_action( self::ACTION_SEND_PHP_ERRORS, [ self::class, 'send_php_errors' ] );

// Register hooks that trigger a debounced site health sync.
self::register_health_sync_hooks();
Expand Down Expand Up @@ -221,6 +228,11 @@ public static function schedule_events(): void {
if ( ! as_has_scheduled_action( self::ACTION_CHECK_MU_PLUGINS, [], self::AS_GROUP ) ) {
as_schedule_recurring_action( time() + HOUR_IN_SECONDS, HOUR_IN_SECONDS, self::ACTION_CHECK_MU_PLUGINS, [], self::AS_GROUP, true );
}

// A few minutes past every hour, apart from the failed logins.
if ( ! as_has_scheduled_action( self::ACTION_SEND_PHP_ERRORS, [], self::AS_GROUP ) ) {
as_schedule_recurring_action( ( intdiv( time(), HOUR_IN_SECONDS ) + 1 ) * HOUR_IN_SECONDS + 8 * MINUTE_IN_SECONDS, HOUR_IN_SECONDS, self::ACTION_SEND_PHP_ERRORS, [], self::AS_GROUP, true );
}
}

/**
Expand Down Expand Up @@ -250,6 +262,17 @@ public static function send_failed_logins(): void {
\Scanfully\Events\FailedLogins\Reporter::send();
}

/**
* Send the PHP errors that are waiting. Runs on the recurring hourly
* schedule and as single runs. Refreshes the access token if needed.
*
* @return void
*/
public static function send_php_errors(): void {
self::refresh_access_token_if_needed();
\Scanfully\Errors\Reporter::send();
}

/**
* Cancel all scheduled email-deliverability actions. Called from the
* scanfully_options_cleared hook on disconnect.
Expand Down
Loading
Loading