Update to Drupal 8.1.9. For more information, see https://www.drupal.org/project/drupal/releases/8.1.9
This commit is contained in:
parent
f9f23cdf38
commit
09b113657a
125 changed files with 2307 additions and 385 deletions
|
@ -113,14 +113,9 @@ class ImageStyleDownloadController extends FileDownloadController {
|
|||
// If using the private scheme, let other modules provide headers and
|
||||
// control access to the file.
|
||||
if ($scheme == 'private') {
|
||||
if (file_exists($derivative_uri)) {
|
||||
return parent::download($request, $scheme);
|
||||
}
|
||||
else {
|
||||
$headers = $this->moduleHandler()->invokeAll('file_download', array($image_uri));
|
||||
if (in_array(-1, $headers) || empty($headers)) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
$headers = $this->moduleHandler()->invokeAll('file_download', array($image_uri));
|
||||
if (in_array(-1, $headers) || empty($headers)) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@ namespace Drupal\image;
|
|||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Routing\UrlGeneratorInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Defines a class to build a listing of image style entities.
|
||||
|
@ -16,40 +13,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class ImageStyleListBuilder extends ConfigEntityListBuilder {
|
||||
|
||||
/**
|
||||
* The URL generator.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\UrlGeneratorInterface
|
||||
*/
|
||||
protected $urlGenerator;
|
||||
|
||||
/**
|
||||
* Constructs a new ImageStyleListBuilder object.
|
||||
*
|
||||
* @param EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $image_style_storage
|
||||
* The image style entity storage class.
|
||||
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
|
||||
* The URL generator.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $image_style_storage, UrlGeneratorInterface $url_generator) {
|
||||
parent::__construct($entity_type, $image_style_storage);
|
||||
$this->urlGenerator = $url_generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
|
||||
return new static(
|
||||
$entity_type,
|
||||
$container->get('entity.manager')->getStorage($entity_type->id()),
|
||||
$container->get('url_generator'),
|
||||
$container->get('string_translation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -87,7 +50,7 @@ class ImageStyleListBuilder extends ConfigEntityListBuilder {
|
|||
public function render() {
|
||||
$build = parent::render();
|
||||
$build['table']['#empty'] = $this->t('There are currently no styles. <a href=":url">Add a new one</a>.', [
|
||||
':url' => $this->urlGenerator->generateFromRoute('image.style_add'),
|
||||
':url' => Url::fromRoute('image.style_add')->toString(),
|
||||
]);
|
||||
return $build;
|
||||
}
|
||||
|
|
|
@ -155,6 +155,11 @@ class ImageStylesPathAndUrlTest extends WebTestBase {
|
|||
$image = $this->container->get('image.factory')->get($generated_uri);
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Type'), $image->getMimeType(), 'Expected Content-Type was reported.');
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Length'), $image->getFileSize(), 'Expected Content-Length was reported.');
|
||||
|
||||
// Check that we did not download the original file.
|
||||
$original_image = $this->container->get('image.factory')->get($original_uri);
|
||||
$this->assertNotEqual($this->drupalGetHeader('Content-Length'), $original_image->getFileSize());
|
||||
|
||||
if ($scheme == 'private') {
|
||||
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
|
||||
$this->assertNotEqual(strpos($this->drupalGetHeader('Cache-Control'), 'no-cache'), FALSE, 'Cache-Control header contains \'no-cache\' to prevent caching.');
|
||||
|
@ -165,6 +170,12 @@ class ImageStylesPathAndUrlTest extends WebTestBase {
|
|||
$this->drupalGet($generate_url);
|
||||
$this->assertResponse(200, 'Image was generated at the URL.');
|
||||
|
||||
// Check that the second request also returned the generated image.
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Length'), $image->getFileSize());
|
||||
|
||||
// Check that we did not download the original file.
|
||||
$this->assertNotEqual($this->drupalGetHeader('Content-Length'), $original_image->getFileSize());
|
||||
|
||||
// Make sure that access is denied for existing style files if we do not
|
||||
// have access.
|
||||
\Drupal::state()->delete('image.test_file_download');
|
||||
|
|
Reference in a new issue