drupal_var_export() initializes a variable that is never used

Created on 13 August 2024, 5 months ago

drupal_var_export() contains the following code.

$line_safe_var = str_replace("\n", '\n', $var);
if (strpos($var, "\n") !== FALSE || strpos($var, "'") !== FALSE) {
  // If the string contains a line break or a single quote, use the
  // double quote export mode. Encode backslash and double quotes and
  // transform some common control characters.
  $var = str_replace(array('\\', '"', "\n", "\r", "\t"), array('\\\\', '\"', '\n', '\r', '\t'), $var);
  $output = '"' . $var . '"';
}
else {
  $output = "'" . $var . "'";
}

$line_safe_var is initialized, but it is never used.

Given that "\n" is replaced with '\n' in the following line, the line initializing $line_safe_var can be removed.

  // If the string contains a line break or a single quote, use the
  // double quote export mode. Encode backslash and double quotes and
  // transform some common control characters.
  $var = str_replace(array('\\', '"', "\n", "\r", "\t"), array('\\\\', '\"', '\n', '\r', '\t'), $var);
🐛 Bug report
Status

Active

Version

7.0 ⚰️

Component
Base 

Last updated about 5 hours ago

Created by

🇮🇹Italy apaderno Brescia, 🇮🇹

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024