- Issue created by @apaderno
- Status changed to Needs review
8 months ago 10:09am 13 August 2024 - Merge request !9190Issue #3467781: drupal_var_export() passes a third argument to itself, when it uses just two parameters → (Closed) created by apaderno
- 🇮🇹Italy apaderno Brescia, 🇮🇹
There is another slight change that could be done.
The actually changed code is the following one.
foreach ($var as $key => $value) { $output .= ' ' . ($export_keys ? drupal_var_export($key) . ' => ' : '') . drupal_var_export($value, ' ') . ",\n"; }
Supposing that
$key
is0
and$value
is'random string with random length'
, that line would be output'random string with random length'
. When$key
is'random key'
and$value
is'another random string with random length'
, that line would be output'random key' => 'another random string with random length'
.
In the first case, there are four spaces before the value$value
; in the second case there are two spaces before the value of$value
, and three spaces after=>
.The following code would avoid that.
foreach ($var as $key => $value) { $output .= ' ' . ($export_keys ? drupal_var_export($key) . ' => ' : '') . drupal_var_export($value) . ",\n"; }
This is a minor change to a line that is already changed. It should not be necessary to open a new issue, but if it necessary, I will create a new issue for this.
- 🇮🇹Italy apaderno Brescia, 🇮🇹
drupal_var_export()
was added in commit 029e7b88. It was not an existing function that was moved to a new file. - Status changed to RTBC
4 months ago 4:32pm 29 November 2024 - 🇸🇰Slovakia poker10
The function does not seems to be used anywhere in D7 core except the scripts to dump the database, but although I would prefer to fix only the parameter issue, so as the MR stands now. Adding a tag for final review, but looks good to me. Thanks!
- 🇮🇹Italy apaderno Brescia, 🇮🇹
(I fixed the function name shown in the issue summary, which could confuse who reads this issue. I apologize for bumping the issue.)
Automatically closed - issue fixed for 2 weeks with no activity.