Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webflo’s picture

Status: Active » Needs review
FileSize
7.72 KB

Status: Needs review » Needs work

The last submitted patch, remove-block-visibility__active_tab-from-cmi-2035725.patch, failed testing.

webflo’s picture

Wrapped this code in isset() because not all blocks have visibility settings.

benjy’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
git apply ~/patches/remove-block-visibility__active_tab-from-cmi-2035725-3.patch
error: patch failed: core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php:170
error: core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php: patch does not apply
error: core/modules/block/tests/config/block.block.stark.test_block.yml: No such file or directory
Sivaji_Ganesh_Jojodae’s picture

Assigned: Unassigned » Sivaji_Ganesh_Jojodae
Issue summary: View changes
Status: Needs work » Needs review
FileSize
6.86 KB

Attaching updated patch.

Status: Needs review » Needs work

The last submitted patch, 5: 2035725_remove_visibility__active_tab_5.patch, failed testing.

Sivaji_Ganesh_Jojodae’s picture

Status: Needs work » Needs review
FileSize
6.86 KB

Re-rolled after a git pull.

Status: Needs review » Needs work

The last submitted patch, 7: 2035725_remove_visibility__active_tab_7.patch, failed testing.

Sivaji_Ganesh_Jojodae’s picture

I'm not sure as what makes the patch fail. It applies cleanly in my local :(

webflo’s picture

webflo’s picture

Status: Needs work » Needs review

go testbot!

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Works for me.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs reroll
+++ b/core/modules/block/lib/Drupal/block/Entity/Block.php
@@ -150,6 +150,9 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
+    if (isset($this->visibility['visibility__active_tab'])) {
+      unset($this->visibility['visibility__active_tab']);
+    }

This is added via form_process_vertical_tabs, and this could happen anywhere. We need a better solution outside the Block entity.

Though if it is block specific, it is BlockFormController's fault, and could be fixed in BlockFormController::submit().

longwave’s picture

NodeTypeFormController has a similar unset() for its vertical tabs.

webflo’s picture

Ok. Move this logic to BlockFormController::submit(). I remove the array key in $settings because i dont want to mess with the form state.

tim.plunkett’s picture

  1. +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
    @@ -318,6 +318,12 @@ public function submit(array $form, array &$form_state) {
    +    // visibility__active_tab is Form API state and not configuration.
    

    This should have an @todo similar to NodeTypeFormController

  2. +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
    @@ -318,6 +318,12 @@ public function submit(array $form, array &$form_state) {
    +    if (isset($settings['values']['visibility']['visibility__active_tab'])) {
    +      unset($settings['values']['visibility']['visibility__active_tab']);
    +    }
    

    You don't need an isset. unset will work just fine by itself, no notices.

webflo’s picture

tim.plunkett’s picture

+++ b/core/modules/config_translation/config_translation.module
@@ -159,7 +159,7 @@ function config_translation_config_translation_type_info_alter(&$definitions) {
-  $definitions['date_format']['form_element_class'] = '\Drupal\config_translation\FormElement\DateFormat';
+  $definitions['date_format']['form_element_class'] = '\Drupal\coBlockFormControllernfig_translation\FormElement\DateFormat';

Somehow this snuck in?

Otherwise looks good.

webflo’s picture

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

The last submitted patch, 15: 2035725_remove_visibility__active_tab_14.patch, failed testing.

The last submitted patch, 17: 2035725_remove_visibility__active_tab_17.patch, failed testing.

catch’s picture

Status: Reviewed & tested by the community » Needs review
benjy’s picture

Status: Needs review » Needs work

What catch says in #23 makes sense to me.

webflo’s picture

Status: Needs work » Needs review
FileSize
8.48 KB
1.42 KB

Ok moved the code to form_state_values_clean.

webflo’s picture

FileSize
7.9 KB
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
@@ -319,6 +319,7 @@ public function submit(array $form, array &$form_state) {

@@ -319,6 +319,7 @@ public function submit(array $form, array &$form_state) {
       'values' => &$form_state['values']['settings'],
       'errors' => $form_state['errors'],
     );
+
     // Call the plugin submit handler.
     $entity->getPlugin()->submitConfigurationForm($form, $settings);
 

Removed this whitespace change.

webflo’s picture

Issue tags: +Needs backport to 7.x
webflo’s picture

I think the patch from comment #19 (RTBC by tim.plunkett) was better. Because there is no generic way to detect where the active tab is stores in $form_state['values']. The active tab state depends on the form structure.

webflo’s picture

Issue tags: +SprintWeekend2014, +D8MA
webflo’s picture

Ok, lets move the vertical tab clenaup to buildEnitty.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, this is the correct fix.

I looked into this a bit because I wondered why this problem does not occur with node types, who also have a vertical tab on the edit form. So I followed the code flow for config entity submit functions.

For both node types as well as blocks the __active_tab information actually makes it into the $entity due to buildEntity() foreach-ing over the the form values and sticking them in there. With node types, however, the vertical tab is in the top-level of the form structure so that it ends up as a top-level property of the entity object. But since that key is not in getExportProperties() it never gets saved into the config.

With block.module, however, the vertical is inside the 'visibility' form key. And 'visibility' is a key in getExportProperties() because it contains needed information. That's why it eventually gets saved into the config.

The correct fix for this is removing the key from the entity itself. We do not want to manipulate the form state, as that is by reference.

For node types this should be done in theory as well, but that's out of scope here and less problematic because it doesn't get saved.

Note: The get() set() business in the patch is needed because 'visibility' is a protected property.

Xano’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
8.39 KB

Re-roll.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

webchick’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Very nice catch!

Committed and pushed to 8.x. Thanks!

Moving back to 7.x for the backport.

tstoeckler’s picture

  • webchick committed 0923a55 on 8.3.x
    Issue #2035725 by webflo, sivaji, Xano: Remove visibility__active_tab...

  • webchick committed 0923a55 on 8.3.x
    Issue #2035725 by webflo, sivaji, Xano: Remove visibility__active_tab...

  • webchick committed 0923a55 on 8.4.x
    Issue #2035725 by webflo, sivaji, Xano: Remove visibility__active_tab...

  • webchick committed 0923a55 on 8.4.x
    Issue #2035725 by webflo, sivaji, Xano: Remove visibility__active_tab...