diff --git a/config/schema/feeds.schema.yml b/config/schema/feeds.schema.yml index b1d137d..292f075 100644 --- a/config/schema/feeds.schema.yml +++ b/config/schema/feeds.schema.yml @@ -118,6 +118,8 @@ feeds.fetcher.http: type: boolean use_pubsubhubbub: type: boolean + always_download: + type: boolean fallback_hub: type: string request_timeout: diff --git a/src/Feeds/Fetcher/Form/HttpFetcherForm.php b/src/Feeds/Fetcher/Form/HttpFetcherForm.php index 299ca36..3a20e1f 100644 --- a/src/Feeds/Fetcher/Form/HttpFetcherForm.php +++ b/src/Feeds/Fetcher/Form/HttpFetcherForm.php @@ -26,6 +26,12 @@ class HttpFetcherForm extends ExternalPluginFormBase { '#description' => $this->t('Attempt to use a PubSubHubbub subscription if available.'), '#default_value' => $this->plugin->getConfiguration('use_pubsubhubbub'), ]; + $form['always_download'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Always Download'), + '#description' => $this->t('Always download the feed, even if the feed has not been updated.'), + '#default_value' => $this->plugin->getConfiguration('always_download'), + ]; $form['fallback_hub'] = [ '#type' => 'url', '#title' => $this->t('Fallback hub'), diff --git a/src/Feeds/Fetcher/HttpFetcher.php b/src/Feeds/Fetcher/HttpFetcher.php index 171917d..2e72174 100644 --- a/src/Feeds/Fetcher/HttpFetcher.php +++ b/src/Feeds/Fetcher/HttpFetcher.php @@ -89,9 +89,10 @@ class HttpFetcher extends PluginBase implements ClearableInterface, FetcherInter // @codingStandardsIgnoreStart // $feed->setSource($response->getEffectiveUrl()); // @codingStandardsIgnoreEnd + $always_download = $this->getConfiguration('always_download'); // 304, nothing to see here. - if ($response->getStatusCode() == Response::HTTP_NOT_MODIFIED) { + if (!$always_download && $response->getStatusCode() == Response::HTTP_NOT_MODIFIED) { $state->setMessage($this->t('The feed has not been updated.')); throw new EmptyFeedException(); } @@ -178,6 +179,7 @@ class HttpFetcher extends PluginBase implements ClearableInterface, FetcherInter // resolved. 'auto_detect_feeds' => FALSE, 'use_pubsubhubbub' => FALSE, + 'always_download' => FALSE, 'fallback_hub' => '', 'request_timeout' => 30, ]; diff --git a/tests/src/Unit/Feeds/Fetcher/Form/HttpFetcherFormTest.php b/tests/src/Unit/Feeds/Fetcher/Form/HttpFetcherFormTest.php index 2c13358..e6520e6 100644 --- a/tests/src/Unit/Feeds/Fetcher/Form/HttpFetcherFormTest.php +++ b/tests/src/Unit/Feeds/Fetcher/Form/HttpFetcherFormTest.php @@ -26,7 +26,7 @@ class HttpFetcherFormTest extends FeedsUnitTestCase { $form_object->setStringTranslation($this->getStringTranslationStub()); $form = $form_object->buildConfigurationForm([], new FormState()); - $this->assertSame(count($form), 4); + $this->assertSame(count($form), 5); } }