diff --git a/src/AddToCampaignHandler.php b/src/AddToCampaignHandler.php index 7c03f6d6..49e5c8a4 100644 --- a/src/AddToCampaignHandler.php +++ b/src/AddToCampaignHandler.php @@ -134,7 +134,7 @@ protected function getAvailableChangeSets() */ protected function getInChangeSets($object) { - $inChangeSetIDs = array_unique(ChangeSetItem::get_for_object($object)->column('ChangeSetID')); + $inChangeSetIDs = array_unique(ChangeSetItem::get_for_object($object)->column('ChangeSetID') ?? []); if ($inChangeSetIDs > 0) { $changeSets = $this->getAvailableChangeSets()->filter([ 'ID' => $inChangeSetIDs, diff --git a/src/CampaignAdmin.php b/src/CampaignAdmin.php index bdc43012..6708b358 100644 --- a/src/CampaignAdmin.php +++ b/src/CampaignAdmin.php @@ -205,7 +205,7 @@ protected function getPlaceholderGroups() $classes = Config::inst()->get(ChangeSet::class, 'important_classes'); foreach ($classes as $class) { - if (!class_exists($class)) { + if (!class_exists($class ?? '')) { continue; } /** @var DataObject $item */ @@ -441,7 +441,7 @@ public function readCampaign(HTTPRequest $request) $accepts = $request->getAcceptMimetypes(); //accept 'text/json' for legacy reasons - if (in_array('application/json', $accepts) || in_array('text/json', $accepts)) { + if (in_array('application/json', $accepts ?? []) || in_array('text/json', $accepts ?? [])) { $response->addHeader('Content-Type', 'application/json'); if (!$request->param('Name')) { return (new HTTPResponse(null, 400)); @@ -788,7 +788,7 @@ public function save($data, $form) $form->loadDataFrom($record); $extra = ['record' => ['id' => $record->ID]]; $response = $this->getSchemaResponse($schemaId, $form, $errors, $extra); - $response->addHeader('X-Status', rawurlencode($message)); + $response->addHeader('X-Status', rawurlencode($message ?? '')); return $response; } diff --git a/tests/behat/src/FixtureContext.php b/tests/behat/src/FixtureContext.php index e332c677..848ca891 100644 --- a/tests/behat/src/FixtureContext.php +++ b/tests/behat/src/FixtureContext.php @@ -125,7 +125,7 @@ public function assertMessageBoxContainsText($text) $mainContext = $this->getMainContext(); $mainContext ->assertSession() - ->elementTextContains('css', '.message-box', str_replace('\\"', '"', $text)); + ->elementTextContains('css', '.message-box', str_replace('\\"', '"', $text ?? '')); } /** @@ -180,7 +180,7 @@ public function iClickTheGalleryItem($name) public function iSeeTheCampaignItem($negate, $name) { $item = $this->getCampaignItem($name); - $shouldSee = !trim($negate); + $shouldSee = !trim($negate ?? ''); if ($shouldSee) { Assert::assertNotNull($item, sprintf('Item "%s" could not be found', $name)); @@ -219,10 +219,10 @@ public function stepCreateCampaignWithItems($id, $data) preg_match_all( '/"(?[^"]+)"\s*=\s*"(?[^"]+)"/', - $data, + $data ?? '', $matches ); - $itemMap = array_combine($matches['content_class'], $matches['identifier']); + $itemMap = array_combine($matches['content_class'] ?? [], $matches['identifier'] ?? []); foreach ($itemMap as $contentClass => $identifier) { $class = $this->convertTypeToClass($contentClass); $record = $this->getFixtureFactory()->get($class, $identifier);