Commit 8546e383 authored by webchick's avatar webchick
Browse files

Issue #1245220 by Berdir, plach, David_Rothstein, dpolant, xjm, WorldFallz,...

Issue #1245220 by Berdir, plach, David_Rothstein, dpolant, xjm, WorldFallz, bfroehle, effulgentsia, corvus_ch | seddonym: Fixed HEAD BROKEN (and change notification/followup): file_file_download() passed bogus  to field_access().
parent 64625f90
......@@ -8,14 +8,14 @@
/**
* Control download access to files.
*
* The hook is typically implemented to limit access based on the entity the
* file is referenced, e.g., only users with access to a node should be allowed
* to download files attached to that node.
* The hook is typically implemented to limit access based on the entity that
* references the file; for example, only users with access to a node should be
* allowed to download files attached to that node.
*
* @param $field
* The field to which the file belongs.
* @param Drupal\entity\EntityInterface $entity
* The $entity to which $file is referenced.
* The entity which references the file.
* @param Drupal\Core\File\File $file
* The file entity that is being requested.
*
......@@ -47,8 +47,8 @@ function hook_file_download_access($field, Drupal\entity\EntityInterface $entity
* values are Boolean grant responses for each module.
* @param array $context
* An associative array containing the following key-value pairs:
* - entity: The entity to which the field item is referenced.
* - field: The field info of the field the field_item belongs to.
* - field: The field to which the file belongs.
* - entity: The entity which references the file.
* - file: The file entity that is being requested.
*
* @return
......
......@@ -63,7 +63,7 @@ function testPrivateFile() {
// Test with the field that should deny access through field access.
$this->drupalLogin($this->admin_user);
$nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, array('private' => TRUE));
$node = node_load($nid, NULL, TRUE);
$node = node_load($nid, TRUE);
$node_file = file_load($node->{$no_access_field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
// Ensure the file cannot be downloaded.
$this->drupalGet(file_create_url($node_file->uri));
......
Supports Markdown
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