Bundle Twilio + AWS SDKs in releases, add SNS install path
Gitea release workflow now runs composer install --no-dev before zipping, so
each release ships vendor/ with both Twilio and AWS SDKs. The plugin's loader
priority is flipped to match: internal vendor/autoload.php first (always
current after every plugin update), external wp-content/twilio-sdk/ second
(legacy/manual install fallback).
AWS SDK detection wired in alongside Twilio: composer's bundled autoloader
covers Aws\… natively when present; otherwise plugin falls back to a new
external location wp-content/aws-sdk/ via install-aws-sdk-external.sh, which
drops the AWS SDK PHAR with a tiny autoload shim. AWS-missing admin notice
fires only when twp_sms_provider === 'aws_sns' so existing Twilio SMS users
see no new noise.
Loader priority flip applied in three places that all had the same
external-first pattern: twilio-wp-plugin.php (twp_check_sdk_installation),
class-twp-twilio-api.php (init_sdk_client), class-twp-webhooks.php
(constructor). twp_check_sdk_after_update messaging updated to reflect that
plugin updates now bundle the SDK.
Files:
.gitea/workflows/release.yml — composer install before ZIP
twilio-wp-plugin.php — TWP_EXTERNAL_AWS_SDK_DIR, dual-SDK
detection, twp_aws_sdk_missing_notice
includes/class-twp-twilio-api.php — internal-first autoloader
includes/class-twp-webhooks.php — internal-first autoloader
install-aws-sdk-external.sh — new AWS SDK PHAR installer
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -39,28 +39,31 @@ class TWP_Twilio_API {
|
||||
|
||||
/**
|
||||
* Initialize Twilio SDK client
|
||||
*
|
||||
* Loader priority:
|
||||
* 1. Internal bundled vendor/autoload.php (shipped with release zip — primary)
|
||||
* 2. External wp-content/twilio-sdk/autoload.php (legacy/manual install fallback)
|
||||
*/
|
||||
private function init_sdk_client() {
|
||||
// Check for SDK autoloader - external location first (survives plugin updates)
|
||||
$autoloader_path = null;
|
||||
|
||||
// Priority 1: External SDK location (recommended)
|
||||
$external_autoloader = TWP_EXTERNAL_SDK_DIR . 'autoload.php';
|
||||
if (file_exists($external_autoloader)) {
|
||||
$autoloader_path = $external_autoloader;
|
||||
// Priority 1: Internal bundled vendor (shipped via release zip)
|
||||
$internal_autoloader = TWP_PLUGIN_DIR . 'vendor/autoload.php';
|
||||
if (file_exists($internal_autoloader)) {
|
||||
$autoloader_path = $internal_autoloader;
|
||||
}
|
||||
|
||||
// Priority 2: Internal vendor directory (fallback)
|
||||
// Priority 2: External legacy SDK location
|
||||
if (!$autoloader_path) {
|
||||
$internal_autoloader = TWP_PLUGIN_DIR . 'vendor/autoload.php';
|
||||
if (file_exists($internal_autoloader)) {
|
||||
$autoloader_path = $internal_autoloader;
|
||||
$external_autoloader = TWP_EXTERNAL_SDK_DIR . 'autoload.php';
|
||||
if (file_exists($external_autoloader)) {
|
||||
$autoloader_path = $external_autoloader;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$autoloader_path) {
|
||||
error_log('TWP Plugin: Autoloader not found. Checked: ' . $external_autoloader . ' and ' . TWP_PLUGIN_DIR . 'vendor/autoload.php');
|
||||
throw new Exception('Twilio SDK not found. Please run: ./install-twilio-sdk-external.sh');
|
||||
error_log('TWP Plugin: Autoloader not found. Checked: ' . TWP_PLUGIN_DIR . 'vendor/autoload.php and ' . TWP_EXTERNAL_SDK_DIR . 'autoload.php');
|
||||
throw new Exception('Twilio SDK not found. Reinstall or update the plugin (release zips bundle the SDK), or run ./install-twilio-sdk-external.sh as a fallback.');
|
||||
}
|
||||
|
||||
// Load the autoloader
|
||||
|
||||
@@ -9,21 +9,21 @@ class TWP_Webhooks {
|
||||
*/
|
||||
public function __construct() {
|
||||
// Load Twilio SDK if not already loaded
|
||||
// Check external location first (survives plugin updates), then internal
|
||||
// Priority: bundled vendor/ first (shipped via release zip), external legacy path as fallback
|
||||
if (!class_exists('\Twilio\Rest\Client')) {
|
||||
$autoloader_path = null;
|
||||
|
||||
// Priority 1: External SDK location
|
||||
$external_autoloader = dirname(dirname(plugin_dir_path(dirname(__FILE__)))) . '/twilio-sdk/autoload.php';
|
||||
if (file_exists($external_autoloader)) {
|
||||
$autoloader_path = $external_autoloader;
|
||||
// Priority 1: Internal bundled vendor directory
|
||||
$internal_autoloader = plugin_dir_path(dirname(__FILE__)) . 'vendor/autoload.php';
|
||||
if (file_exists($internal_autoloader)) {
|
||||
$autoloader_path = $internal_autoloader;
|
||||
}
|
||||
|
||||
// Priority 2: Internal vendor directory
|
||||
// Priority 2: External legacy SDK location
|
||||
if (!$autoloader_path) {
|
||||
$internal_autoloader = plugin_dir_path(dirname(__FILE__)) . 'vendor/autoload.php';
|
||||
if (file_exists($internal_autoloader)) {
|
||||
$autoloader_path = $internal_autoloader;
|
||||
$external_autoloader = dirname(dirname(plugin_dir_path(dirname(__FILE__)))) . '/twilio-sdk/autoload.php';
|
||||
if (file_exists($external_autoloader)) {
|
||||
$autoloader_path = $external_autoloader;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user