Skip to content
Snippets Groups Projects
Verified Commit fee08681 authored by Dave Long's avatar Dave Long
Browse files

Issue #3017054 by alexpott, deviantintegral, percoction, mattwith,...

Issue #3017054 by alexpott, deviantintegral, percoction, mattwith, ankithashetty, Wim Leers, jwilson3, longwave, bircher: Consistently sort filter formats to simplify config exports

(cherry picked from commit 5f533ca6)
parent 90c16a3b
Branches
Tags
20 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump,!5950Issue #3403653 by alexpott, longwave: Incorporate improvements to how contrib runs PHPStan to core,!5858Issue #3401971 by fjgarlin: Test-only job shouldn't require constant rebases...,!5716Draft: Issue #3401102 by Spokje, longwave, smustgrave: Nightwatch artifacts on GitLab not retained,!5674Transaction autocommit during shutdown relies on unreliable object destruction order,!5644Issue #3395563 by nireneko, marvil07, lauriii, borisson_, smustgrave, Wim...
Pipeline #47983 passed
Pipeline: drupal

#47984

    Showing
    with 307 additions and 257 deletions
    ......@@ -9,15 +9,12 @@ weight: 0
    roles:
    - authenticated
    filters:
    filter_html:
    id: filter_html
    provider: filter
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: -10
    settings:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <span> <img src alt height width data-entity-type data-entity-uuid data-align data-caption>'
    filter_html_help: false
    filter_html_nofollow: false
    weight: 11
    settings: { }
    filter_align:
    id: filter_align
    provider: filter
    ......@@ -30,15 +27,18 @@ filters:
    status: true
    weight: 8
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    status: true
    weight: -10
    settings:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <span> <img src alt height width data-entity-type data-entity-uuid data-align data-caption>'
    filter_html_help: false
    filter_html_nofollow: false
    filter_html_image_secure:
    id: filter_html_image_secure
    provider: filter
    status: true
    weight: 9
    settings: { }
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: 11
    settings: { }
    ......@@ -9,14 +9,18 @@ name: 'Plain text'
    format: plain_text
    weight: 10
    filters:
    # Escape all HTML.
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_html_escape:
    id: filter_html_escape
    provider: filter
    status: true
    weight: -10
    settings: { }
    # Convert URLs into links.
    filter_url:
    id: filter_url
    provider: filter
    ......@@ -24,10 +28,3 @@ filters:
    weight: 0
    settings:
    filter_url_length: 72
    # Convert linebreaks into paragraphs.
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    ......@@ -37,6 +37,7 @@ filter.format.*:
    label: 'Role'
    filters:
    type: sequence
    orderby: key
    label: 'Enabled filters'
    sequence:
    type: filter
    ......
    <?php
    /**
    * @file
    * Post update functions for Filter.
    */
    use Drupal\Core\Config\Entity\ConfigEntityUpdater;
    use Drupal\filter\Entity\FilterFormat;
    /**
    * Sorts filter format filter configuration.
    */
    function filter_post_update_sort_filters(?array &$sandbox = NULL): void {
    $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class);
    $config_entity_updater->update($sandbox, 'filter_format', function (FilterFormat $format): bool {
    $sorted_filters = $filters = array_keys($format->get('filters'));
    sort($sorted_filters);
    return $sorted_filters !== $filters;
    });
    }
    ......@@ -202,10 +202,13 @@ public function disable() {
    * {@inheritdoc}
    */
    public function preSave(EntityStorageInterface $storage) {
    // Ensure the filters have been sorted before saving.
    $this->filters()->sort();
    parent::preSave($storage);
    if (!$this->isSyncing() && $this->hasTrustedData()) {
    // Filters are sorted by keys to ensure config export diffs are easy to
    // read and there is a minimal changeset. If the save is not trusted then
    // the configuration will be sorted by StorableConfigBase.
    ksort($this->filters);
    }
    assert(is_string($this->label()), 'Filter format label is expected to be a string.');
    $this->name = trim($this->label());
    ......
    ......@@ -7,18 +7,18 @@ roles:
    - anonymous
    - authenticated
    filters:
    filter_html_escape:
    id: filter_html_escape
    provider: filter
    status: true
    weight: -10
    settings: { }
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_html_escape:
    id: filter_html_escape
    provider: filter
    status: true
    weight: -10
    settings: { }
    filter_url:
    id: filter_url
    provider: filter
    ......
    ......@@ -2,14 +2,14 @@ name: 'Filtered HTML'
    format: filtered_html
    weight: 1
    filters:
    filter_url:
    id: filter_url
    provider: filter
    status: true
    weight: -1
    filter_html:
    id: filter_html
    provider: filter
    status: true
    settings:
    allowed_html: '<p> <br> <strong> <a href hreflang>'
    filter_url:
    id: filter_url
    provider: filter
    status: true
    weight: -1
    <?php
    namespace Drupal\Tests\filter\Functional;
    use Drupal\FunctionalTests\Update\UpdatePathTestBase;
    /**
    * Tests the upgrade path for filter formats.
    *
    * @see views_post_update_fix_revision_id_part()
    *
    * @group Update
    * @group legacy
    */
    class FilterFormatUpdateFilterSortingTest extends UpdatePathTestBase {
    /**
    * {@inheritdoc}
    */
    protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
    __DIR__ . '/../../../../system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz',
    ];
    }
    /**
    * Tests filter_post_update_sort_filters().
    */
    public function testFilterPostUpdateSortFilters() {
    $format_config = $this->config('filter.format.plain_text');
    $this->assertSame(['filter_html_escape', 'filter_url', 'filter_autop'], array_keys($format_config->get('filters')));
    $this->runUpdates();
    $format_config = $this->config('filter.format.plain_text');
    $this->assertSame(['filter_autop', 'filter_html_escape', 'filter_url'], array_keys($format_config->get('filters')));
    }
    }
    ......@@ -419,14 +419,14 @@ public function testFilterFormatPreSave() {
    // Use config to directly load the configuration and check that only enabled
    // or customized plugins are saved to configuration.
    $filters = $this->config('filter.format.crazy')->get('filters');
    $this->assertEquals(['filter_html_escape', 'filter_html'], array_keys($filters));
    $this->assertEquals(['filter_html', 'filter_html_escape'], array_keys($filters));
    // Disable a plugin to ensure that disabled plugins with custom settings are
    // stored in configuration.
    $crazy_format->setFilterConfig('filter_html_escape', ['status' => FALSE]);
    $crazy_format->save();
    $filters = $this->config('filter.format.crazy')->get('filters');
    $this->assertEquals(['filter_html_escape', 'filter_html'], array_keys($filters));
    $this->assertEquals(['filter_html', 'filter_html_escape'], array_keys($filters));
    // Set the settings as per default to ensure that disable plugins in this
    // state are not stored in configuration.
    ......
    ......@@ -91,7 +91,7 @@ public function testFilterFormat() {
    $this->assertEntity('custom_text_format', 'Custom Text format', ['filter_autop' => 0, 'filter_html' => -10], 0, TRUE);
    $this->assertEntity('filtered_html', 'Filtered HTML', ['filter_autop' => 2, 'filter_html' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 0, TRUE);
    $this->assertEntity('full_html', 'Full HTML', ['filter_autop' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 1, TRUE);
    $this->assertEntity('plain_text', 'Plain text', ['filter_html_escape' => 0, 'filter_url' => 1, 'filter_autop' => 2], 10, TRUE);
    $this->assertEntity('plain_text', 'Plain text', ['filter_autop' => 2, 'filter_html_escape' => 0, 'filter_url' => 1], 10, TRUE);
    // This assertion covers issue #2555089. Drupal 7 formats are identified
    // by machine names, so migrated formats should be merged into existing
    // ones.
    ......
    ......@@ -10,51 +10,51 @@ name: 'Basic HTML'
    format: basic_html
    weight: 0
    filters:
    filter_html:
    id: filter_html
    provider: filter
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: -10
    settings:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <img src alt loading height width data-entity-type data-entity-uuid data-align data-caption> <drupal-media data-entity-type data-entity-uuid data-view-mode data-align data-caption alt title>'
    filter_html_help: false
    filter_html_nofollow: false
    weight: 11
    settings: { }
    filter_align:
    id: filter_align
    provider: filter
    status: true
    weight: 7
    settings: { }
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_caption:
    id: filter_caption
    provider: filter
    status: true
    weight: 8
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    status: true
    weight: -10
    settings:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <img src alt loading height width data-entity-type data-entity-uuid data-align data-caption> <drupal-media data-entity-type data-entity-uuid data-view-mode data-align data-caption alt title>'
    filter_html_help: false
    filter_html_nofollow: false
    filter_html_image_secure:
    id: filter_html_image_secure
    provider: filter
    status: true
    weight: 9
    settings: { }
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: 11
    settings: { }
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_image_lazy_load:
    id: filter_image_lazy_load
    provider: filter
    status: true
    weight: 15
    settings: { }
    settings: { }
    media_embed:
    id: media_embed
    provider: media
    ......
    ......@@ -10,6 +10,12 @@ name: 'Full HTML'
    format: full_html
    weight: 2
    filters:
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: 11
    settings: { }
    filter_align:
    id: filter_align
    provider: filter
    ......@@ -22,6 +28,15 @@ filters:
    status: true
    weight: 9
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    status: false
    weight: -10
    settings:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <s> <sup> <sub> <table> <caption> <tbody> <thead> <tfoot> <th> <td> <tr> <hr> <p> <h1> <pre> <drupal-media data-entity-type data-entity-uuid data-view-mode data-align data-caption alt title>'
    filter_html_help: true
    filter_html_nofollow: false
    filter_htmlcorrector:
    id: filter_htmlcorrector
    provider: filter
    ......@@ -33,22 +48,7 @@ filters:
    provider: filter
    status: true
    weight: 15
    settings: { }
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: 11
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    status: false
    weight: -10
    settings:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <s> <sup> <sub> <table> <caption> <tbody> <thead> <tfoot> <th> <td> <tr> <hr> <p> <h1> <pre> <drupal-media data-entity-type data-entity-uuid data-view-mode data-align data-caption alt title>'
    filter_html_help: true
    filter_html_nofollow: false
    media_embed:
    id: media_embed
    provider: media
    ......
    ......@@ -7,6 +7,12 @@ weight: 1
    roles:
    - anonymous
    filters:
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    ......@@ -16,12 +22,6 @@ filters:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>'
    filter_html_help: true
    filter_html_nofollow: false
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_url:
    id: filter_url
    provider: filter
    ......
    ......@@ -7,6 +7,12 @@ weight: 1
    roles:
    - anonymous
    filters:
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    ......@@ -16,12 +22,6 @@ filters:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>'
    filter_html_help: true
    filter_html_nofollow: false
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_url:
    id: filter_url
    provider: filter
    ......
    ......@@ -9,15 +9,12 @@ weight: 0
    roles:
    - authenticated
    filters:
    filter_html:
    id: filter_html
    provider: filter
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: -10
    settings:
    allowed_html: '<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>'
    filter_html_help: false
    filter_html_nofollow: false
    weight: 11
    settings: { }
    filter_align:
    id: filter_align
    provider: filter
    ......@@ -30,6 +27,15 @@ filters:
    status: true
    weight: 8
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    status: true
    weight: -10
    settings:
    allowed_html: '<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>'
    filter_html_help: false
    filter_html_nofollow: false
    filter_html_image_secure:
    id: filter_html_image_secure
    provider: filter
    ......@@ -42,9 +48,3 @@ filters:
    status: true
    weight: 15
    settings: { }
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: 11
    settings: { }
    ......@@ -9,6 +9,12 @@ weight: 2
    roles:
    - administrator
    filters:
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: 11
    settings: { }
    filter_align:
    id: filter_align
    provider: filter
    ......@@ -32,10 +38,4 @@ filters:
    provider: filter
    status: true
    weight: 15
    settings: { }
    editor_file_reference:
    id: editor_file_reference
    provider: editor
    status: true
    weight: 11
    settings: { }
    ......@@ -7,6 +7,12 @@ weight: 1
    roles:
    - anonymous
    filters:
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_html:
    id: filter_html
    provider: filter
    ......@@ -16,12 +22,6 @@ filters:
    allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>'
    filter_html_help: true
    filter_html_nofollow: false
    filter_autop:
    id: filter_autop
    provider: filter
    status: true
    weight: 0
    settings: { }
    filter_url:
    id: filter_url
    provider: filter
    ......
    This diff is collapsed.
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment