From bc091dd69dbbf764f9db5a203821e904223f45f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 5 May 2026 08:48:30 -0700 Subject: [PATCH 1/3] Fix fatal "TWP_Activator not found" on voicemail webhook callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The activator class was only loaded during plugin activation, on admin_init when the DB version differed, and in a few explicit admin handlers. Twilio webhook callbacks (voicemail in particular, but also any non-admin caller of TWP_Activator::force_table_updates() / ::ensure_tables_exist()) hit the public REST endpoint where none of those load paths fire, so the static call fataled. Load class-twp-activator.php in TWP_Core::load_dependencies() so every plugin context — webhook, REST, cron, admin — has the class available. The activator file is a pure class definition with no load-time side effects. This single change covers all 9 runtime call sites (webhook, scheduler, and six admin sites) that previously assumed the class would already be loaded. Co-Authored-By: Claude Opus 4.7 (1M context) --- includes/class-twp-core.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/class-twp-core.php b/includes/class-twp-core.php index 99d0b01..475b5ad 100644 --- a/includes/class-twp-core.php +++ b/includes/class-twp-core.php @@ -29,7 +29,12 @@ class TWP_Core { private function load_dependencies() { // Loader class require_once TWP_PLUGIN_DIR . 'includes/class-twp-loader.php'; - + + // Activator (defines TWP_Activator). Loaded here so runtime callers in + // webhook/REST/cron contexts can use ::ensure_tables_exist() and + // ::force_table_updates() without each site needing its own require_once. + require_once TWP_PLUGIN_DIR . 'includes/class-twp-activator.php'; + // API classes require_once TWP_PLUGIN_DIR . 'includes/class-twp-twilio-api.php'; require_once TWP_PLUGIN_DIR . 'includes/class-twp-elevenlabs-api.php'; -- 2.47.3 From ee8e11197052eb4d5dd5d379bb50e8d69ba7df0a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 5 May 2026 08:48:45 -0700 Subject: [PATCH 2/3] Bundle Twilio + AWS SDKs in releases, add SNS install path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .gitea/workflows/release.yml | 9 +++ includes/class-twp-twilio-api.php | 25 +++--- includes/class-twp-webhooks.php | 18 ++--- install-aws-sdk-external.sh | 121 ++++++++++++++++++++++++++++++ twilio-wp-plugin.php | 110 +++++++++++++++++++-------- 5 files changed, 233 insertions(+), 50 deletions(-) create mode 100755 install-aws-sdk-external.sh diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index a8dda6a..998bddf 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -16,6 +16,15 @@ jobs: password: ${{ secrets.CI_TOKEN }} fetch-depth: 0 # Important: Fetch all history for commit messages + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + tools: composer + + - name: Install Composer dependencies + run: composer install --no-dev --prefer-dist --optimize-autoloader --no-interaction + - name: Get version id: get_version run: | diff --git a/includes/class-twp-twilio-api.php b/includes/class-twp-twilio-api.php index 9b7f647..9059817 100644 --- a/includes/class-twp-twilio-api.php +++ b/includes/class-twp-twilio-api.php @@ -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 diff --git a/includes/class-twp-webhooks.php b/includes/class-twp-webhooks.php index 4e11c3a..1c6d03f 100644 --- a/includes/class-twp-webhooks.php +++ b/includes/class-twp-webhooks.php @@ -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; } } diff --git a/install-aws-sdk-external.sh b/install-aws-sdk-external.sh new file mode 100755 index 0000000..efa0b9b --- /dev/null +++ b/install-aws-sdk-external.sh @@ -0,0 +1,121 @@ +#!/bin/bash + +# Script to install AWS SDK for PHP to an external location +# This prevents SDK from being deleted when WordPress updates the plugin +# +# Location: wp-content/aws-sdk/ (outside plugin folder) +# +# Uses the official single-file PHAR distribution from aws/aws-sdk-php releases. +# The PHAR ships its own composer-generated autoloader, so no PSR-4 wiring needed. + +echo "Installing AWS SDK for PHP (latest) to external location..." +echo "This will install the SDK outside the plugin folder to survive plugin updates." + +# Check if we can download files +if ! command -v curl &> /dev/null; then + echo "ERROR: curl is required to download the SDK" + echo "Please install curl and try again" + exit 1 +fi + +# Get the script directory (plugin directory) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Calculate wp-content directory (two levels up from plugin) +# Plugin is at: wp-content/plugins/twilio-wp-plugin/ +# We want: wp-content/aws-sdk/ +WP_CONTENT_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")" +SDK_DIR="$WP_CONTENT_DIR/aws-sdk" + +echo "Plugin directory: $SCRIPT_DIR" +echo "SDK will be installed to: $SDK_DIR" + +# Create SDK directory +mkdir -p "$SDK_DIR" + +# Download the latest PHAR release +echo "Downloading AWS SDK PHAR from GitHub..." +TEMP_DIR=$(mktemp -d) +cd "$TEMP_DIR" + +if ! curl -L https://github.com/aws/aws-sdk-php/releases/latest/download/aws.phar -o aws.phar; then + echo "ERROR: Failed to download AWS SDK PHAR" + echo "Please check your internet connection and try again" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Verify the download is non-empty (PHAR is roughly 12 MB) +if [ ! -s "$TEMP_DIR/aws.phar" ]; then + echo "ERROR: Downloaded AWS SDK PHAR is empty or missing" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Remove existing SDK if it exists +if [ -f "$SDK_DIR/aws.phar" ]; then + echo "Removing existing AWS SDK installation..." + rm -f "$SDK_DIR/aws.phar" +fi + +# Move the PHAR into place +echo "Installing SDK files..." +if ! mv "$TEMP_DIR/aws.phar" "$SDK_DIR/aws.phar"; then + echo "ERROR: Failed to move AWS SDK PHAR into place" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Create the autoloader shim +cat > "$SDK_DIR/autoload.php" << 'EOF' +
-

Twilio WordPress Plugin - SDK Required

+

Twilio WordPress Plugin - Twilio SDK Required

The Twilio PHP SDK is required for this plugin to work.

-

Recommended: Install SDK to external location (survives plugin updates):

+

Recommended: Reinstall or update the plugin. Plugin updates now bundle the SDK (the release zip ships a pre-built vendor/ directory), so a fresh install or update is the simplest fix.

+

Legacy / manual install: If you can't update the plugin, you can install the SDK to the external location instead:

chmod +x install-twilio-sdk-external.sh && ./install-twilio-sdk-external.sh -

Alternative: Install SDK inside plugin folder:

- chmod +x install-twilio-sdk.sh && ./install-twilio-sdk.sh

Plugin path:

-

External SDK path:

+

Bundled vendor path:

+

External SDK fallback path:

+
+ +
+

Twilio WordPress Plugin - AWS SDK Required for SNS SMS

+

You have selected AWS SNS as your SMS provider, but the AWS PHP SDK is not available.

+

Recommended: Update the plugin to a release-bundled version — newer release zips bundle the AWS SDK alongside the Twilio SDK in vendor/.

+

Legacy / manual install: Install the AWS SDK to the external location:

+ chmod +x install-aws-sdk-external.sh && ./install-aws-sdk-external.sh +

External AWS SDK path:

+

If you don't need AWS SNS, switch the SMS provider back to Twilio under the plugin settings.

-

Twilio WordPress Plugin - SDK Reinstall Required

-

The plugin was updated and the Twilio SDK needs to be reinstalled.

-

To prevent this in the future, install the SDK to the external location:

+

Twilio WordPress Plugin - SDK Missing After Update

+

The plugin was updated, but no Twilio SDK could be found.

+

Plugin release zips normally bundle the SDK in vendor/, so this usually means the release was built without dependencies, or the upload was incomplete. Try downloading the release zip again and reinstalling.

+

Manual install fallback:

cd && ./install-twilio-sdk-external.sh -

The external SDK at survives plugin updates.

+

Bundled vendor path:

+

External SDK fallback path:

Date: Tue, 5 May 2026 08:50:40 -0700 Subject: [PATCH 3/3] Track Gradle wrapper scripts and ignore .flutter-plugins The Gradle wrapper jar and properties were already tracked but the matching gradlew (bash) and gradlew.bat (Windows) launcher scripts were not, leaving the wrapper unusable without a separately-installed Gradle. Adding both so ./gradlew works on a fresh clone. .flutter-plugins is a generated file containing absolute machine-specific pub-cache paths and is explicitly marked "do not check into version control" in its own header. Adding it to mobile/.gitignore alongside the already- ignored .flutter-plugins-dependencies. Co-Authored-By: Claude Opus 4.7 (1M context) --- mobile/.gitignore | 1 + mobile/android/gradlew | 160 +++++++++++++++++++++++++++++++++++++ mobile/android/gradlew.bat | 90 +++++++++++++++++++++ 3 files changed, 251 insertions(+) create mode 100755 mobile/android/gradlew create mode 100755 mobile/android/gradlew.bat diff --git a/mobile/.gitignore b/mobile/.gitignore index 3820a95..ba6d238 100644 --- a/mobile/.gitignore +++ b/mobile/.gitignore @@ -27,6 +27,7 @@ migrate_working_dir/ **/doc/api/ **/ios/Flutter/.last_build_id .dart_tool/ +.flutter-plugins .flutter-plugins-dependencies .pub-cache/ .pub/ diff --git a/mobile/android/gradlew b/mobile/android/gradlew new file mode 100755 index 0000000..9d82f78 --- /dev/null +++ b/mobile/android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/mobile/android/gradlew.bat b/mobile/android/gradlew.bat new file mode 100755 index 0000000..aec9973 --- /dev/null +++ b/mobile/android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega -- 2.47.3