Skip to content
Snippets Groups Projects
Verified Commit 1ea22bd4 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2815829 by godotislate, tim.plunkett, smustgrave, alexpott, xjm,...

Issue #2815829 by godotislate, tim.plunkett, smustgrave, alexpott, xjm, bircher, paulocs: Adding or editing a block through the UI saves the entity twice

(cherry picked from commit 24b8523c)
parent d0b79059
No related branches found
No related tags found
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 #37724 failed
Pipeline: drupal

#37731

    Pipeline: drupal

    #37730

      Pipeline: drupal

      #37729

        +1
        ......@@ -44,7 +44,12 @@ public function getConfiguration() {
        unset($instance_config['context_mapping']);
        ksort($default_config);
        ksort($instance_config);
        if ($default_config === $instance_config) {
        // With PHP 8 type juggling, there should not be an issue using equal
        // operator instead of identical operator. Allowing looser comparison here
        // will prevent configuration from being erroneously exported when values
        // are updated via form elements that return values of the wrong type, for
        // example, '0'/'1' vs FALSE/TRUE.
        if ($default_config == $instance_config) {
        unset($configuration[$instance_id]);
        }
        }
        ......
        ......@@ -327,13 +327,6 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
        protected function validateVisibility(array $form, FormStateInterface $form_state) {
        // Validate visibility condition settings.
        foreach ($form_state->getValue('visibility') as $condition_id => $values) {
        // All condition plugins use 'negate' as a Boolean in their schema.
        // However, certain form elements may return it as 0/1. Cast here to
        // ensure the data is in the expected type.
        if (array_key_exists('negate', $values)) {
        $form_state->setValue(['visibility', $condition_id, 'negate'], (bool) $values['negate']);
        }
        // Allow the condition to validate the form.
        $condition = $form_state->get(['conditions', $condition_id]);
        $condition->validateConfigurationForm($form['visibility'][$condition_id], SubformState::createForSubform($form['visibility'][$condition_id], $form, $form_state));
        ......@@ -360,9 +353,13 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
        }
        $this->submitVisibility($form, $form_state);
        }
        // Save the settings of the plugin.
        $entity->save();
        /**
        * {@inheritdoc}
        */
        public function save(array $form, FormStateInterface $form_state) {
        $value = parent::save($form, $form_state);
        $this->messenger()->addStatus($this->t('The block configuration has been saved.'));
        $form_state->setRedirect(
        ......@@ -372,6 +369,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
        ],
        ['query' => ['block-placement' => Html::getClass($this->entity->id())]]
        );
        return $value;
        }
        /**
        ......
        <?php
        namespace Drupal\KernelTests\Core\Condition;
        use Drupal\Core\Condition\ConditionPluginCollection;
        use Drupal\KernelTests\KernelTestBase;
        /**
        * @coversDefaultClass \Drupal\Core\Condition\ConditionPluginCollection
        *
        * @group Condition
        */
        class ConditionPluginCollectionTest extends KernelTestBase {
        /**
        * {@inheritdoc}
        */
        protected static $modules = [
        'system',
        'user',
        'path_alias',
        ];
        /**
        * @covers ::getConfiguration
        */
        public function testGetConfiguration(): void {
        // Include a condition that has custom configuration and a type mismatch on
        // 'negate' by using 0 instead of FALSE.
        $configuration['request_path'] = [
        'id' => 'request_path',
        'negate' => 0,
        'context_mapping' => [],
        'pages' => '/user/*',
        ];
        // Include a condition that matches default values but with a type mismatch
        // on 'negate' by using 0 instead of FALSE. This condition will be removed,
        // because condition configurations that match default values with "=="
        // comparison are not saved or exported.
        $configuration['user_role'] = [
        'id' => 'user_role',
        'negate' => '0',
        'context_mapping' => [],
        'roles' => [],
        ];
        $collection = new ConditionPluginCollection(\Drupal::service('plugin.manager.condition'), $configuration);
        $expected['request_path'] = [
        'id' => 'request_path',
        'negate' => 0,
        'context_mapping' => [],
        'pages' => '/user/*',
        ];
        // NB: The 'user_role' property should not exist in expected set.
        $this->assertSame($expected, $collection->getConfiguration());
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment