The CTools exporter, by default, adds a prefix of two spaces to the beginning of sub-variable that it exports. This works well for exporting arrays and such as it nicely formats the output. The problem, though, is that, when it exports multiline scalars (mainly strings), it unconditionally adds those two spaces to the beginning of each line in the multiline scalar. This is bad since it's altering the contents of the variable without consent. For us, it's mainly an annoyance right now, because each time we export a feature containing a Panel with PHP code or multiline CSS, every time we re-export it, it pushes the contents further to the right because of that unconditional indentation. The attached patch changes that behavior so that the prefix is only applied if the variable being exported is not a scalar.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | ctools-no_indent_scalars-758750.patch | 1.03 KB | snufkin |
| #1 | ctools-no_indent_scalars-758750-1.patch | 711 bytes | mgriego |
| ctools_export_no_prefix_for_scalars.patch | 371 bytes | mgriego |
Comments
Comment #1
mgriego commentedSo the patch I attached initially actually sucks. It only solves part of the problem. Scalars can still be modified if they're embedded in a nested array. The attached patch is much better as it solves the real problem instead of being a workaround.
Comment #2
mgriego commentedWe have been using this in our environment for a while now, and it has definitely helped to make the module exports more VCS-friendly.
Comment #3
snufkin commentedI have also patched it here: #727772: Multiple line php variables are re-indented in consequtive exports, but i havent worked with scalars in arrays, so this solution is probably a better one.
Comment #4
mgriego commentedThanks. I didn't see that when I went searching for this issue. My patch in #1 does fully fix the problem. Your patch is very close to my patch in the initial issue, which can still cause indentation to happen. I've added a note to that issue to reference this one.
Comment #5
snufkin commentedRerolling for CVS version and fixing patch so patch -p0 actually works on it. Also fixed coding standard issues with concatenation.
This is a really annoying issue and this patch does fix it for me too.
Comment #6
sdboyer commentedWe use the new standards on string concatenation (always have): http://drupal.org/coding-standards#concat - which means both of you got them wrong :P
Fixed & committed. Thanks!