Download & Extend

DrupalLocalStreamWrapper::stream_open() uses a local variable instead of the argument passed by reference

Project:Drupal core
Version:8.x-dev
Component:file system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:Needs issue summary update

Issue Summary

API page: http://api.drupal.org/api/drupal/includes--stream_wrappers.inc/function/...

The function, instead of updating the value of the argument passes by reference, initialize the value of a local variable.

<?php
public function stream_open($uri, $mode, $options, &$opened_path) {
 
$this->uri = $uri;
 
$path = $this->getLocalPath();
 
$this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);

  if ((bool)
$this->handle && $options & STREAM_USE_PATH) {
   
$opened_url = $path;
  }

  return (bool)
$this->handle;
}
?>

The parameter is &$opened_path, but the used variable is $opened_url. This means the caller doesn't get back the path of the file being opened.

Comments

#1

Version:7.x-dev» 8.x-dev

#2

Status:active» needs review
AttachmentSizeStatusTest resultOperations
parameter-for-stream-open-1224802.patch539 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 33,594 pass(es).View details

#3

Status:needs review» reviewed & tested by the community

#4

Tagging issues not yet using summary template.

#5

Status:reviewed & tested by the community» fixed

Good catch. Committed to 7.x and 8.x.

#6

Status:fixed» closed (fixed)

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

nobody click here