Problem/Motivation

I have run into an issue on a project which I think is going to crop up repeatedly and substantially increases risk of configuration conflicts resulting in branch merge issues; let me explain:

The webform fields are all in a single string in the form's yaml file as "elements", typically if there are changes by two developers on Drupal configuration, the changes are easy to view and merge as yaml has one setting per line. The elements string however presents a massive line with multiple changes.

Scenario 1: single branch conflicts

The initial issue came about where two developers were committing configuration changes to a webform configuration while working on the same branch. These although confusing were simple to merge as the deviation was manageable within that branch.

Scenario 2: feature branch conflicts

We have moved the project onto strict feature branch code management, which for the most part is a great idea, but for webform elements config, it is a nightmare.

  • Developer needs to make a webform elements change
    • branch from Master to new feature branch
    • merge into develop for testing
  • -- All OK at this point --
  • Developer needs to make another webform elements change
    • branch from Master to new feature branch (note branching off master again, so I don't have the other changes)
    • merge into develop for testing
    • deal with conflicts in elements string
  • -- Got confusing with the merge --
  • -- Do another --
  • -- And another --
  • -- Some changes are accepted for UAT --
  • Developer re-merges some of the above feature branches into UAT branch (integration branch, develop branch being merged to master is potentially messy)
    • Again deal with conflicts in elements string (but this is prone to error as it requires painstaking diff evaluation for each feature with changes to the webform)

Sorry I am trying to clearly state the issue, not sure I have managed.

Proposed resolution

You are the YAML expert, but would it be possible for the webform fields yaml to be stored in another configuration file? (shooting in the dark here)

Any suggestions anyone else?

PS: please don't read my tone as anything but constructive, the work done on this module is AMAZING.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

duncan.moo created an issue. See original summary.

jrockowitz’s picture

My immediate workaround was to create a `drush webform-tidy` command that converts the single line of elements to multiple lines of text, which makes it much easier to merge exported configuration.

Right now, the `drush webform-tidy` command only tidies exported module configuration but it could be updated to support a path and maybe even a config filename prefix as arguments.

drush webform-tidy --path='default/config_RYGDKJNWKJAHKJ/sync' -- prefix="webform"

Ideally, there should be a way to override the YAML serializer in core and tidy exported config, but this is not possible.

I feel this is a core issue since any YAML config containing multiple lines of text is more difficult to merge.

jrockowitz’s picture

Status: Active » Needs review
FileSize
3.42 KB

The attached patch allows for a `drush webform-tidy sync` command.

jrockowitz’s picture

  • jrockowitz committed f3b01a2 on 8.x-5.x
    Issue #2910850 by jrockowitz: Webform configuration git and elements...
jrockowitz’s picture

I committed the patch. Please download the latest release to review.

Now, you can add `drush webform-tidy sync` to your workflow when exporting config and git merges should be much easier.

The longterm solution would be to tidy all exported config in core. I am doubtful Drupal 8 core can alter the format of exported configuration files because this could break backward compatibility.

jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ABaier’s picture

Hey Jacob,

I just tried to use this command and it seems to be not working if the config folder lies outside of the files directory.

We have the folders 'config' and 'config-local' (using the config_split module) one level above the web root, overridden in the settings.php. Since you removed the --path option, would there be a way to target the actively used config directories?

Thanks for your help!

jrockowitz’s picture

Status: Closed (fixed) » Needs work

We should restore the --path option.

@ABaier Can you provide a patch?

ABaier’s picture

Sorry Jacob, unfortunately I have never done that before and it would exceed my coding knowledge. Just saw it in comment #2 and thought that maybe could be a solution.

jrockowitz’s picture

Status: Needs work » Active

@ABaier No prob moving to 'Active'. I will try to get to this task in the next two weeks.

ABaier’s picture

Great, thank you! I will try to help with testing and feedback.

jrockowitz’s picture

Status: Active » Needs review
FileSize
3.97 KB

I decide to keep the command simple and you can just use drush webform-tidy /some/path

jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

ABaier’s picture

Thanks Jacob! Works as expected. It seems that these changes were not yet in the latest dev branch, but I tested them manually.

I could successfully tidy all the webform config files in my custom directory using drush webform-tidy /some/path and also a single file adding --prefix=webform.webform.filename. An import of these tidied files also worked without any problems.

  • jrockowitz committed 6b21d44 on 8.x-5.x
    Issue #2910850 by jrockowitz: Webform configuration git and elements...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.