Compare commits

...

2 Commits

Author SHA1 Message Date
Claude
78e6c5a4ee Fix fatal error: WP_REST_Server::get_request() does not exist
All checks were successful
Create Release / build (push) Successful in 6s
Store authenticated user ID on the auth object instance instead of
trying to retrieve it from the REST server request. This was the root
cause of all mobile API 500 errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 11:44:46 -08:00
Claude
eedb7bdb8f Fix auto-updater to fetch newest release by creation date
All checks were successful
Create Release / build (push) Successful in 3s
Use /releases?limit=1 instead of /releases/latest which sorts by
semver tag. Date-based tags (2026.03.06-1805) have a hyphen that
semver treats as a prerelease separator, causing incorrect ordering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 18:59:23 -08:00
2 changed files with 14 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ class TWP_Auto_Updater {
public function __construct() { public function __construct() {
$this->plugin_basename = plugin_basename(dirname(dirname(__FILE__)) . '/twilio-wp-plugin.php'); $this->plugin_basename = plugin_basename(dirname(dirname(__FILE__)) . '/twilio-wp-plugin.php');
$this->current_version = defined('TWP_VERSION') ? TWP_VERSION : '0.0.0'; $this->current_version = defined('TWP_VERSION') ? TWP_VERSION : '0.0.0';
$this->gitea_api_url = $this->gitea_base_url . '/api/v1/repos/' . $this->gitea_repo . '/releases/latest'; $this->gitea_api_url = $this->gitea_base_url . '/api/v1/repos/' . $this->gitea_repo . '/releases?limit=1&draft=false';
} }
/** /**
@@ -74,7 +74,7 @@ class TWP_Auto_Updater {
$custom_repo = get_option('twp_gitea_repo', ''); $custom_repo = get_option('twp_gitea_repo', '');
if (!empty($custom_repo)) { if (!empty($custom_repo)) {
$this->gitea_repo = $custom_repo; $this->gitea_repo = $custom_repo;
$this->gitea_api_url = $this->gitea_base_url . '/api/v1/repos/' . $this->gitea_repo . '/releases/latest'; $this->gitea_api_url = $this->gitea_base_url . '/api/v1/repos/' . $this->gitea_repo . '/releases?limit=1&draft=false';
} }
$update_info = $this->get_latest_release(); $update_info = $this->get_latest_release();
@@ -184,9 +184,16 @@ class TWP_Auto_Updater {
return false; return false;
} }
$release = json_decode($response); $releases = json_decode($response);
if (!$release || !isset($release->tag_name)) { if (!$releases || !is_array($releases) || empty($releases)) {
error_log('TWP Auto-Updater: No releases found from Gitea');
return false;
}
$release = $releases[0];
if (!isset($release->tag_name)) {
error_log('TWP Auto-Updater: Invalid release data from Gitea'); error_log('TWP Auto-Updater: Invalid release data from Gitea');
return false; return false;
} }

View File

@@ -9,6 +9,7 @@ class TWP_Mobile_Auth {
private $secret_key; private $secret_key;
private $token_expiry = 86400; // 24 hours in seconds private $token_expiry = 86400; // 24 hours in seconds
private $refresh_expiry = 2592000; // 30 days in seconds private $refresh_expiry = 2592000; // 30 days in seconds
private $current_user_id = null;
/** /**
* Constructor * Constructor
@@ -330,7 +331,7 @@ class TWP_Mobile_Auth {
} }
// Store user ID for later use // Store user ID for later use
$request->set_param('_twp_user_id', $payload->user_id); $this->current_user_id = $payload->user_id;
return true; return true;
} }
@@ -339,8 +340,7 @@ class TWP_Mobile_Auth {
* Get current user ID from token * Get current user ID from token
*/ */
public function get_current_user_id() { public function get_current_user_id() {
$request = rest_get_server()->get_request(); return $this->current_user_id;
return $request->get_param('_twp_user_id');
} }
/** /**