From a5b6ea96440655a72f33bed05a509a2ae194802f Mon Sep 17 00:00:00 2001 From: David Cameron <david@cadeyrn.us> Date: Thu, 7 Sep 2023 00:12:14 -0500 Subject: [PATCH] Issue #2283877 by dcam, larowlan: Remove or use Aggregator's teaser_length setting --- aggregator.install | 9 +++++ config/install/aggregator.settings.yml | 1 - config/schema/aggregator.schema.yml | 3 -- migrations/d6_aggregator_settings.yml | 2 -- migrations/d7_aggregator_settings.yml | 2 -- .../aggregator/processor/DefaultProcessor.php | 13 -------- tests/src/Functional/AggregatorAdminTest.php | 1 - ...torUpdateDeleteTeaserLengthSettingTest.php | 33 +++++++++++++++++++ .../d6/MigrateAggregatorConfigsTest.php | 1 - .../d7/MigrateAggregatorSettingsTest.php | 1 - 10 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 tests/src/Functional/Update/AggregatorUpdateDeleteTeaserLengthSettingTest.php diff --git a/aggregator.install b/aggregator.install index c646717ec..1e063de73 100644 --- a/aggregator.install +++ b/aggregator.install @@ -61,6 +61,15 @@ function aggregator_update_8601() { $view_config->save(); } +/** + * Remove the teaser_length admin setting. + */ +function aggregator_update_8602() { + $settings = \Drupal::configFactory()->getEditable('aggregator.settings'); + $settings->clear('items.teaser_length') + ->save(); +} + /** * Determines whether the RSS view config has been altered from the default. * diff --git a/config/install/aggregator.settings.yml b/config/install/aggregator.settings.yml index be3a20179..20c446254 100644 --- a/config/install/aggregator.settings.yml +++ b/config/install/aggregator.settings.yml @@ -4,7 +4,6 @@ processors: - aggregator items: allowed_html: '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>' - teaser_length: 600 expire: 9676800 source: list_max: 3 diff --git a/config/schema/aggregator.schema.yml b/config/schema/aggregator.schema.yml index eb6c006f6..7d14ad92e 100644 --- a/config/schema/aggregator.schema.yml +++ b/config/schema/aggregator.schema.yml @@ -23,9 +23,6 @@ aggregator.settings: allowed_html: type: string label: 'Allowed HTML tags' - teaser_length: - type: integer - label: 'Length of trimmed description' expire: type: integer label: 'Discard items older than' diff --git a/migrations/d6_aggregator_settings.yml b/migrations/d6_aggregator_settings.yml index a620f69ea..ed2e82c83 100644 --- a/migrations/d6_aggregator_settings.yml +++ b/migrations/d6_aggregator_settings.yml @@ -10,7 +10,6 @@ source: - aggregator_parser - aggregator_processors - aggregator_allowed_html_tags - - aggregator_teaser_length - aggregator_clear - aggregator_summary_items source_module: aggregator @@ -19,7 +18,6 @@ process: parser: aggregator_parser processors: aggregator_processors 'items/allowed_html': aggregator_allowed_html_tags - 'items/teaser_length': aggregator_teaser_length 'items/expire': aggregator_clear 'source/list_max': aggregator_summary_items destination: diff --git a/migrations/d7_aggregator_settings.yml b/migrations/d7_aggregator_settings.yml index 3e4583ef8..8aadc1c62 100644 --- a/migrations/d7_aggregator_settings.yml +++ b/migrations/d7_aggregator_settings.yml @@ -10,7 +10,6 @@ source: - aggregator_parser - aggregator_processors - aggregator_allowed_html_tags - - aggregator_teaser_length - aggregator_clear - aggregator_summary_items source_module: aggregator @@ -19,7 +18,6 @@ process: parser: aggregator_parser processors: aggregator_processors 'items/allowed_html': aggregator_allowed_html_tags - 'items/teaser_length': aggregator_teaser_length 'items/expire': aggregator_clear 'source/list_max': aggregator_summary_items destination: diff --git a/src/Plugin/aggregator/processor/DefaultProcessor.php b/src/Plugin/aggregator/processor/DefaultProcessor.php index 53c42cc89..7b43b1fc2 100644 --- a/src/Plugin/aggregator/processor/DefaultProcessor.php +++ b/src/Plugin/aggregator/processor/DefaultProcessor.php @@ -166,18 +166,6 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor '#description' => t('Requires a correctly configured <a href=":cron">cron maintenance task</a>.', [':cron' => Url::fromRoute('system.status')->toString()]), ]; - $lengths = [0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]; - $options = array_map(function ($length) { - return ($length == 0) ? t('Unlimited') : $this->formatPlural($length, '1 character', '@count characters'); - }, array_combine($lengths, $lengths)); - - $form['processors'][$info['id']]['aggregator_teaser_length'] = [ - '#type' => 'select', - '#title' => t('Length of trimmed description'), - '#default_value' => $config->get('items.teaser_length'), - '#options' => $options, - '#description' => t('The maximum number of characters used in the trimmed version of content.'), - ]; return $form; } @@ -186,7 +174,6 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['items']['expire'] = $form_state->getValue('aggregator_clear'); - $this->configuration['items']['teaser_length'] = $form_state->getValue('aggregator_teaser_length'); $this->configuration['source']['list_max'] = $form_state->getValue('aggregator_summary_items'); // @todo Refactor aggregator plugins to ConfigEntity so this is not needed. $this->setConfiguration($this->configuration); diff --git a/tests/src/Functional/AggregatorAdminTest.php b/tests/src/Functional/AggregatorAdminTest.php index 6e6ed2b2d..088aa4514 100644 --- a/tests/src/Functional/AggregatorAdminTest.php +++ b/tests/src/Functional/AggregatorAdminTest.php @@ -31,7 +31,6 @@ class AggregatorAdminTest extends AggregatorTestBase { 'aggregator_allowed_html_tags' => '<a>', 'aggregator_summary_items' => 10, 'aggregator_clear' => 3600, - 'aggregator_teaser_length' => 200, 'aggregator_fetcher' => 'aggregator_test_fetcher', 'aggregator_parser' => 'aggregator_test_parser', 'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor', diff --git a/tests/src/Functional/Update/AggregatorUpdateDeleteTeaserLengthSettingTest.php b/tests/src/Functional/Update/AggregatorUpdateDeleteTeaserLengthSettingTest.php new file mode 100644 index 000000000..45c2dc0cb --- /dev/null +++ b/tests/src/Functional/Update/AggregatorUpdateDeleteTeaserLengthSettingTest.php @@ -0,0 +1,33 @@ +<?php + +namespace Drupal\Tests\aggregator\Functional\Update; + +use Drupal\FunctionalTests\Update\UpdatePathTestBase; + +/** + * @covers aggregator_update_8602() + * @group Update + * @group aggregator + */ +class AggregatorUpdateDeleteTeaserLengthSettingTest extends UpdatePathTestBase { + + /** + * {@inheritdoc} + */ + protected function setDatabaseDumpFiles() { + $this->databaseDumpFiles = [ + DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz', + __DIR__ . '/../../../fixtures/update/aggregator.php', + ]; + } + + /** + * Ensure the items.teaser_length setting is deleted. + */ + public function testUpdateHookN(): void { + $this->runUpdates(); + $settings = \Drupal::config('aggregator.settings'); + $this->assertNull($settings->get('items.teaser_length')); + } + +} diff --git a/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php b/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php index bd3df58e5..2f520151d 100644 --- a/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php +++ b/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php @@ -29,7 +29,6 @@ class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase { $this->assertSame('aggregator', $config->get('fetcher')); $this->assertSame('aggregator', $config->get('parser')); $this->assertSame(['aggregator'], $config->get('processors')); - $this->assertSame(600, $config->get('items.teaser_length')); $this->assertSame('<a> <b> <br /> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>', $config->get('items.allowed_html')); $this->assertSame(9676800, $config->get('items.expire')); $this->assertSame(3, $config->get('source.list_max')); diff --git a/tests/src/Kernel/Migrate/d7/MigrateAggregatorSettingsTest.php b/tests/src/Kernel/Migrate/d7/MigrateAggregatorSettingsTest.php index 3b11917e2..19809eb03 100644 --- a/tests/src/Kernel/Migrate/d7/MigrateAggregatorSettingsTest.php +++ b/tests/src/Kernel/Migrate/d7/MigrateAggregatorSettingsTest.php @@ -27,7 +27,6 @@ class MigrateAggregatorSettingsTest extends MigrateDrupal7TestBase { $this->assertSame('aggregator', $config['parser']); $this->assertSame(['aggregator'], $config['processors']); $this->assertSame('<p> <div> <a>', $config['items']['allowed_html']); - $this->assertSame(500, $config['items']['teaser_length']); $this->assertSame(86400, $config['items']['expire']); $this->assertSame(6, $config['source']['list_max']); } -- GitLab