diff --git a/includes/class-twp-auto-updater.php b/includes/class-twp-auto-updater.php index d13f265..a09f4cf 100644 --- a/includes/class-twp-auto-updater.php +++ b/includes/class-twp-auto-updater.php @@ -19,7 +19,7 @@ class TWP_Auto_Updater { public function __construct() { $this->plugin_basename = plugin_basename(dirname(dirname(__FILE__)) . '/twilio-wp-plugin.php'); $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', ''); if (!empty($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(); @@ -184,9 +184,16 @@ class TWP_Auto_Updater { 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'); return false; }