Commit 2290a306 authored by Steffen Schlaer's avatar Steffen Schlaer
Browse files

Issue #3261232 by IT-Cru, lhridley, Project Update Bot: Check and prepare D10 readiness

parent f222d2a0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -15,13 +15,13 @@
    "source": "https://cgit.drupalcode.org/image_style_warmer"
  },
  "require-dev": {
    "drush/drush": "^9.0 || ^10"
    "drush/drush": "^10 || ^11"
  },
  "license": "GPL-2.0+",
  "extra": {
    "drush": {
      "services": {
        "drush.services.yml": "^9"
        "drush.services.yml": "^9 || ^10 || ^11"
      }
    }
  }
+2 −2
Original line number Diff line number Diff line
services:
  image_style_warmer.commands:
    class: \Drupal\image_style_warmer\Commands\ImageStylesWarmerCommands
    arguments: [ '@logger.factory' ]
    class: \Drupal\image_style_warmer\Commands\ImageStyleWarmerCommands
    arguments: [ '@logger.factory', '@entity_type.manager' ]
    tags:
      - { name: drush.command }
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ configure: image_style_warmer.settings
package: Performance

type: module
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^9 || ^10

dependencies:
  - drupal:image
+25 −4
Original line number Diff line number Diff line
@@ -3,17 +3,38 @@
namespace Drupal\image_style_warmer\Commands;

use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drush\Commands\DrushCommands;

class ImageStylesWarmerCommands extends DrushCommands {
/**
 * Image Style Warmer Drush Commands.
 */
class ImageStyleWarmerCommands extends DrushCommands {

  use StringTranslationTrait;

  /**
   * Logger Channel Factory Service.
   *
   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
   */
  private $loggerChannelFactory;

  public function __construct(LoggerChannelFactoryInterface $loggerChannelFactory) {
  /**
   * File Entity Storage interface.
   *
   * @var \Drupal\Core\Entity\EntityStorageInterface
   */
  private $fileEntityStorage;

  /**
   * Constructs a new ImageStyleWarmerCommands object.
   */
  public function __construct(LoggerChannelFactoryInterface $loggerChannelFactory, EntityTypeManagerInterface $entityTypeManager) {
    parent::__construct();
    $this->loggerChannelFactory = $loggerChannelFactory;
    $this->fileEntityStorage = $entityTypeManager->getStorage('file');
  }

  /**
@@ -26,7 +47,7 @@ class ImageStylesWarmerCommands extends DrushCommands {
    $this->logger()->notice("Loading files.");
    $this->loggerChannelFactory->get('image_style_warmer')->info('Image styles warmer loading files.');

    $files = \Drupal::entityQuery('file')->execute();
    $files = $this->fileEntityStorage->getQuery()->accessCheck(FALSE)->execute();
    if (!empty($files)) {
      $count = count($files);
      $numOperations = 0;
@@ -42,7 +63,7 @@ class ImageStylesWarmerCommands extends DrushCommands {
      }

      $batch = [
        'title' => t('Warming up image styles for @num file(s)', ['@num' => $numOperations]),
        'title' => $this->t('Warming up image styles for @num file(s)', ['@num' => $numOperations]),
        'operations' => $operations,
        'finished' => '\Drupal\image_style_warmer\BatchService::warmUpFileFinished',
      ];
+1 −27
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ class ImageStyleWarmerDrushTest extends ImageStyleWarmerTestBase {
   */
  public function testDrushWarmUpMessages() {
    // Run the plain command using the full image-style-warmer:warm-up command
    // name, and check that all of the output messages are shown.
    // name, and check that all the output messages are shown.
    $this->drush('image-style-warmer:warm-up');
    $messages = $this->getErrorOutput();
    $this->assertStringContainsString('No files found', $messages, 'No files found message not found', TRUE);
@@ -39,30 +39,4 @@ class ImageStyleWarmerDrushTest extends ImageStyleWarmerTestBase {
    $this->assertStringContainsString('Batch operations end', $messages, 'Batch operations end message not found', TRUE);
  }

  /**
   * Prepare Image Style Warmer settings and file for tests.
   *
   * @param bool $permanent
   *   Create permanent file for tests. (default: FALSE)
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  public function prepareImageStyleWarmerTests($permanent = FALSE) {
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/config/development/performance/image-style-warmer');
    $settings = [
      'initial_image_styles[test_initial]' => 'test_initial',
      'queue_image_styles[test_queue]' => 'test_queue',
    ];
    $this->submitForm($settings, t('Save configuration'));

    // Create an image file without usages.
    $this->testFile = $this->getTestFile('image');
    $this->testFile->setTemporary();
    if ($permanent) {
      $this->testFile->setPermanent();
    }
    $this->testFile->save();
  }

}
Loading