This is a follow-up issue for #1229014: Content-Disposition header makes private files show open/save prompts, but public files show inline.

file_get_content_headers() defines a variable named $name but it's not used.

It was used for the "Content-Disposition" header before the patch in #1229014: Content-Disposition header makes private files show open/save prompts, but public files show inline was committed. But it's not used currently.


function file_get_content_headers($file) {
  $name = mime_header_encode($file->filename);
  $type = mime_header_encode($file->filemime);

  return array(
    'Content-Type' => $type,
    'Content-Length' => $file->filesize,
    'Cache-Control' => 'private',
  );
}

The variable was already removed in D8.


function file_get_content_headers(FileInterface $file) {
  $type = Unicode::mimeHeaderEncode($file->getMimeType());

  return array(
    'Content-Type' => $type,
    'Content-Length' => $file->getSize(),
    'Cache-Control' => 'private',
  );
}

https://api.drupal.org/api/drupal/core%21modules%21file%21file.module/fu...

This variable isn't harmful but an existence of an unused variable is confusing for developers, I think.

Comments

hgoto created an issue. See original summary.

hgoto’s picture

Status: Active » Needs review
StatusFileSize
new419 bytes
smaaz’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Novice

Applied and tested, the patch works cleanly.

renatog’s picture

StatusFileSize
new23.54 KB

Hi guys.

It really makes sense.

Good Work.

Regards.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x - thanks!

  • David_Rothstein committed f72778c on 7.x
    Issue #2853160 by hgoto, RenatoG: Variable $name is defined but not used...

  • David_Rothstein committed 8238d81 on 7.x
    Issue #2853160 by hgoto, smaaz: Variable $name is defined but not used...
  • David_Rothstein committed c58a1f1 on 7.x
    Revert "Issue #2853160 by hgoto, RenatoG: Variable $name is defined but...
David_Rothstein’s picture

Reverted and committed it again, but this time crediting the correct people in the commit message.

Status: Fixed » Closed (fixed)

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