Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed undefine errors #21760

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions inc/class-addon-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ protected function get_site_information_default() {
*/
protected function map_site_information( $site_information ) {
return (object) [
'url' => $site_information->url,
'subscriptions' => array_map( [ $this, 'map_subscription' ], $site_information->subscriptions ),
'url' => $site_information->url ?? null,
'subscriptions' => array_map( [ $this, 'map_subscription' ], $site_information->subscriptions ?? [] ),
];
}

Expand All @@ -831,17 +831,16 @@ protected function map_site_information( $site_information ) {
protected function map_subscription( $subscription ) {
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Not our properties.
return (object) [
'renewal_url' => $subscription->renewalUrl,
'expiry_date' => $subscription->expiryDate,
'renewal_url' => $subscription->renewalUrl ?? null,
'expiry_date' => $subscription->expiryDate ?? null,
'product' => (object) [
'version' => $subscription->product->version,
'name' => $subscription->product->name,
'slug' => $subscription->product->slug,
'last_updated' => $subscription->product->lastUpdated,
'store_url' => $subscription->product->storeUrl,
// Ternary operator is necessary because download can be undefined.
'download' => ( $subscription->product->download ?? null ),
'changelog' => $subscription->product->changelog,
'version' => $subscription->product->version ?? null,
'name' => $subscription->product->name ?? null,
'slug' => $subscription->product->slug ?? null,
'last_updated' => $subscription->product->lastUpdated ?? null,
'store_url' => $subscription->product->storeUrl ?? null,
'download' => $subscription->product->download ?? null,
'changelog' => $subscription->product->changelog ?? null,
],
];
// phpcs:enable
Expand Down