diff --git a/src/DonationForms/V2/Endpoints/ListDonationForms.php b/src/DonationForms/V2/Endpoints/ListDonationForms.php index f90aff393d..f5d1472fa8 100644 --- a/src/DonationForms/V2/Endpoints/ListDonationForms.php +++ b/src/DonationForms/V2/Endpoints/ListDonationForms.php @@ -136,7 +136,7 @@ public function handleRequest(WP_REST_Request $request): WP_REST_Response $this->listTable->items($forms, $this->request->get_param('locale') ?? ''); $items = $this->listTable->getItems(); - $defaultCampaignForm = Campaign::find($this->request->get_param('campaignId'))->defaultForm(); + $defaultCampaignForm = ($campaignId = $this->request->get_param('campaignId')) ? Campaign::find($campaignId)->defaultForm() : false; foreach ($items as $i => &$item) { $item['name'] = get_the_title($item['id']); @@ -144,7 +144,7 @@ public function handleRequest(WP_REST_Request $request): WP_REST_Response $item['permalink'] = get_permalink($item['id']); $item['v3form'] = (bool)give_get_meta($item['id'], 'formBuilderSettings'); $item['status_raw'] = $forms[$i]->status->getValue(); - $item['isDefaultCampaignForm'] = $item['id'] === $defaultCampaignForm->id; + $item['isDefaultCampaignForm'] = $defaultCampaignForm && $item['id'] === $defaultCampaignForm->id; } }