CI / Coding Standards (pull_request) Successful in 28s
CI / Tests (PHP 8.1) (pull_request) Successful in 35s
CI / No Debug Code (pull_request) Successful in 9s
CI / Tests (PHP 8.3) (pull_request) Successful in 44s
CI / Tests (PHP 8.2) (pull_request) Successful in 47s
CI / Tests (PHP 8.5) (pull_request) Successful in 48s
CI / Static Analysis (pull_request) Successful in 52s
CI / Build Plugin Zip (pull_request) Skipped
The daily billing scan runs on request via WP-Cron and can overlap itself under concurrent traffic. Each run emailed the payments it created with no record that a notice had gone out, so two overlapping runs could send a payer two identical "Payment due" emails for one charge — read by families as being billed twice, though only one row exists. Stamp us_payments.notice_sent_at atomically before emailing: the scan now claims each payment with a conditional UPDATE ... WHERE notice_sent_at IS NULL and only notices, credits and batches the rows it won. A competing run finds them claimed and stays quiet, so exactly one notice is sent regardless of how the scan is triggered. A one-time backfill stamps existing scheduled rows on upgrade so already-noticed charges are not re-emailed. Co-authored-by: anthropic/claude-opus-4-8
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Unsupervised Scheduler
|
|
* Plugin URI: https://git.unsupervised.ca/Unsupervised/unsupervised-scheduler
|
|
* Description: Instructor/student lesson scheduling for WordPress.
|
|
* Version: 1.5.8
|
|
* Requires at least: 6.2
|
|
* Requires PHP: 8.1
|
|
* Author: Unsupervised
|
|
* Author URI: https://unsupervised.ca
|
|
* License: GPL-2.0-or-later
|
|
* Text Domain: unsupervised-schedular
|
|
* Update URI: https://git.unsupervised.ca/Unsupervised/unsupervised-scheduler
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular;
|
|
|
|
if (! defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
define('USC_VERSION', '1.5.8');
|
|
define('USC_PLUGIN_FILE', __FILE__);
|
|
define('USC_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
define('USC_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|
define('USC_TABLE_AVAILABILITY', $GLOBALS['wpdb']->prefix . 'us_availability');
|
|
define('USC_TABLE_LESSONS', $GLOBALS['wpdb']->prefix . 'us_lessons');
|
|
|
|
require_once USC_PLUGIN_DIR . 'vendor/autoload.php';
|
|
|
|
register_activation_hook(__FILE__, static function (): void {
|
|
(new Installer())->run();
|
|
});
|
|
|
|
register_deactivation_hook(__FILE__, static function (): void {
|
|
wp_clear_scheduled_hook('us_generate_due_payments');
|
|
flush_rewrite_rules();
|
|
});
|
|
|
|
add_action('plugins_loaded', static function (): void {
|
|
Plugin::boot();
|
|
});
|