Commit e4ee841e authored by Primoz Hmeljak's avatar Primoz Hmeljak Committed by Primoz Hmeljak
Browse files

Issue #3303102 by Primsi: Undefined array key "X-Ratelimit-Limit" error

parent 3c5cbfbb
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -410,10 +410,15 @@ class PexelsWidget extends WidgetBase {
        $results = $this->pexelsClient
          ->setApiKey($this->configuration['api_key'])
          ->search($input['keyword'], $this->defaultPerPage, $page, $input['orientation'] ?: '', $input['color'] ?: '');

        if (!isset($results['contents'])) {
          throw new \Exception('Result contents were empty.');
        }

        $search_results = $results['contents'];
      }
      catch (\Exception $e) {
        $this->messenger()->addError('There was an error while fetching the results. Please contact the system administrator.');
        $this->messenger()->addError($this->t('There was an error while fetching the results. Please contact the system administrator.'));
        $this->loggerFactory->get('media_pexels')->error($e->getMessage());
        return $form;
      }