Skip to content

Commit

Permalink
fix(updater): prevent undefined property and foreach errors by valida…
Browse files Browse the repository at this point in the history
…ting `required_plugins` in version check

- Added validation for `required_plugins` to ensure it exists and is an array or object before processing.
- Prevented `Undefined property` and `foreach` errors when `required_plugins` is not set in `$version_info`.
  • Loading branch information
anisAronno committed Aug 22, 2024
1 parent bccd2bb commit 58be238
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ public function check_plugin_update($transient_data)

// If new version available, set to response
if (version_compare($this->client->project_version, $version_info->new_version, '<')) {
$warnings = $this->check_required_plugins($version_info->required_plugins);
$required_plugins = isset($version_info->required_plugins) && (is_array($version_info->required_plugins) || is_object($version_info->required_plugins))
? $version_info->required_plugins
: [];

$warnings = $this->check_required_plugins($required_plugins);

if (!empty($warnings)) {
$this->show_warning_notice($warnings);
Expand Down

0 comments on commit 58be238

Please sign in to comment.