diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8d198a1b7..0e7d0ed3a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -22,9 +22,6 @@ jobs: drupal-core: '10.2.x' phpstan: '0' # We only need to run PHPStan once on the latest PHP version. - - php-versions: '8.3' - drupal-core: '10.3.x' - phpstan: '1' - php-versions: '8.3' drupal-core: '11.0.x' phpstan: '1' diff --git a/src/GraphQL/Utility/FileUpload.php b/src/GraphQL/Utility/FileUpload.php index 7d1aff08c..baad4374c 100644 --- a/src/GraphQL/Utility/FileUpload.php +++ b/src/GraphQL/Utility/FileUpload.php @@ -514,7 +514,6 @@ protected function prepareFilename(string $filename, array &$validators): string // If the file will be rejected anyway due to a disallowed extension, it // should not be renamed; rather, we'll let fileValidator service // to validate FileExtension reject it below. - $passes_validation = FALSE; if (!empty($validators['FileExtension']['extensions'])) { /** @var \Drupal\file\FileInterface $file */ diff --git a/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php b/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php index a77d32ad7..b727f0a49 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php @@ -98,11 +98,18 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable $metadata->addCacheableDependency($access); if ($access->isAllowed() && $image_style = ImageStyle::load($style)) { - /** @var \Drupal\Core\Image\ImageInterface $image */ - $image = \Drupal::service('image.factory')->get($entity->getFileUri()); - if ($image->isValid()) { - $width = $image->getWidth(); - $height = $image->getHeight(); + // @phpstan-ignore-next-line + $width = $entity->width; + // @phpstan-ignore-next-line + $height = $entity->height; + + if (!isset($width) || !isset($height)) { + /** @var \Drupal\Core\Image\ImageInterface $image */ + $image = \Drupal::service('image.factory')->get($entity->getFileUri()); + if ($image->isValid()) { + $width = $image->getWidth(); + $height = $image->getHeight(); + } } // Determine the dimensions of the styled image. diff --git a/src/Routing/QueryRouteEnhancer.php b/src/Routing/QueryRouteEnhancer.php index ae063b4f9..079f90e49 100644 --- a/src/Routing/QueryRouteEnhancer.php +++ b/src/Routing/QueryRouteEnhancer.php @@ -92,6 +92,7 @@ protected function assertValidPostRequestHeaders(Request $request) : void { return; } + // @phpstan-ignore-next-line $content_format = method_exists($request, 'getContentTypeFormat') ? $request->getContentTypeFormat() : $request->getContentType(); if ($content_format === NULL) { // Symfony before 5.4 does not detect "multipart/form-data", check for it diff --git a/tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageDerivativeTest.php b/tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageDerivativeTest.php index 375fff3ae..18ef12b7c 100644 --- a/tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageDerivativeTest.php +++ b/tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageDerivativeTest.php @@ -62,6 +62,11 @@ public function setUp(): void { $this->file->method('getFileUri')->willReturn($this->fileUri); $this->file->method('access')->willReturn((new AccessResultAllowed())->addCacheTags(['test_tag'])); + // @todo Remove hard-coded properties and only rely on image factory. + // @phpstan-ignore-next-line + @$this->file->width = 600; + // @phpstan-ignore-next-line + @$this->file->height = 400; $this->style = ImageStyle::create(['name' => 'test_style']); $effect = [ diff --git a/tests/src/Kernel/DataProducer/EntityReferenceTest.php b/tests/src/Kernel/DataProducer/EntityReferenceTest.php index 3b7700eff..976ce0e14 100644 --- a/tests/src/Kernel/DataProducer/EntityReferenceTest.php +++ b/tests/src/Kernel/DataProducer/EntityReferenceTest.php @@ -5,9 +5,8 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; -use Drupal\Tests\graphql\Kernel\GraphQLTestBase; use Drupal\Tests\field\Traits\EntityReferenceFieldCreationTrait; - +use Drupal\Tests\graphql\Kernel\GraphQLTestBase; /** * Tests the entity_reference data producers.