Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The function features_var_export first check if the first parameter '$var' is an object like so :
if (is_object($var)) {
$output = method_exists($var, 'export') ? $var->export() : features_var_export((array) $var);
}
and the last thing the function does, is replacing '***BREAK***' with '\n' only if '$init' is TRUE
if ($init) {
$output = str_replace("***BREAK***", "\n", $output);
}
if you pass an object with arrays , everything works good, but if you pass an array of objetcs, the replacement happens too early and it adds spaces in the string.
anyway, this patch solve the problem !
doing this :
if (is_object($var)) {
$output = method_exists($var, 'export') ? $var->export() : features_var_export((array) $var, $prefix, FALSE);
}
instead of this :
if (is_object($var)) {
$output = method_exists($var, 'export') ? $var->export() : features_var_export((array) $var);
}
Comment | File | Size | Author |
---|---|---|---|
features.patch | 727 bytes | emman31 | |
Comments
Comment #1
mpotter CreditAttribution: mpotter commentedUnfortunately, that just goes back to how the code used to be. See this issue #1505044: features_var_export adds additional prefix to multiline strings contained in objects.
So we need a way to handle both cases properly and I cannot commit the patch as it is. Also marking this for D7 since we fix stuff in D7 first and then back-port to D6.
Comment #2
emman31 CreditAttribution: emman31 commentedBoth patch are (almost) same !
I don't have a D7 version right now, can't try it on Drupal 7
Comment #3
mpotter CreditAttribution: mpotter commentedI think the problem might be that you are not using the latest 1.x-dev version of Features. The current code is:
$output = method_exists($var, 'export') ? $var->export() : features_var_export((array) $var, '', FALSE);
which is different than what your patch is applied against. So your patch doesn't apply.
Comment #4
emman31 CreditAttribution: emman31 commentedWell, this Issue is a duplicate of the one you linked.
And I just checked on D7 code and it seems already ported to D7.
Only one thing though, is it ok to call features_var_export with an empty string as $prefix parameter ? Shouldn't we pass the same prefix instead ? (It's the only difference between my patch and the one already applied)
Comment #5
kenorb CreditAttribution: kenorb commented#1505044: features_var_export adds additional prefix to multiline strings contained in objects