Commit 4f1f28ae authored by Dries's avatar Dries
Browse files

- Patch #992674 by carlos8f, scor, alexanderpas: private file download returns access denied.

parent 43fac0b2
......@@ -141,7 +141,7 @@ function file_file_download($uri, $field_type = 'file') {
}
// Find out which (if any) fields of this type contain the file.
$references = file_get_file_references($file, NULL, FIELD_LOAD_REVISION, $field_type);
$references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, $field_type);
// If there are no references, stop processing, to avoid returning headers
// for files controlled by other modules.
......
......@@ -121,20 +121,23 @@ class FileFieldTestCase extends DrupalWebTestCase {
);
if (is_numeric($nid_or_type)) {
$node = node_load($nid_or_type, NULL, TRUE);
$delta = isset($node->{$field_name}[LANGUAGE_NONE]) ? count($node->{$field_name}[LANGUAGE_NONE]) : 0;
$edit['files[' . $field_name . '_' . LANGUAGE_NONE . '_' . $delta . ']'] = drupal_realpath($file->uri);
$this->drupalPost('node/' . $nid_or_type . '/edit', $edit, t('Save'));
$nid = $nid_or_type;
}
else {
$edit['files[' . $field_name . '_' . LANGUAGE_NONE . '_0]'] = drupal_realpath($file->uri);
$type_name = str_replace('_', '-', $nid_or_type);
$this->drupalPost('node/add/' . $type_name, $edit, t('Save'));
// Add a new node.
$node = $this->drupalCreateNode(array('type' => $nid_or_type));
$nid = $node->nid;
// Save at least one revision to better simulate a real site.
$this->drupalCreateNode(get_object_vars($node));
$node = node_load($nid, NULL, TRUE);
$this->assertNotEqual($nid, $node->vid, t('Node revision exists.'));
}
$matches = array();
preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
return isset($matches[1]) ? $matches[1] : FALSE;
// Attach a file to the node.
$edit['files[' . $field_name . '_' . $langcode . '_0]'] = drupal_realpath($file->uri);
$this->drupalPost("node/$nid/edit", $edit, t('Save'));
return $nid;
}
/**
......@@ -1001,7 +1004,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Load the node and the file.
$node = node_load($nid);
$node = node_load($nid, NULL, TRUE);
$file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
$file->description = 'File description.';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment