diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 36d04e24fc..ea552bf4cb 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -322,33 +322,6 @@ public static function fromUri($uri, $options = []) { return $url; } - /** - * Creates a new Url object from an external URL. - * - * @param string $external_url - * An URL string, will not be checked for syntax. - * @param array $options - * (optional) An associative array of additional URL options, with the - * following elements: - * - 'query': An array of query key/value-pairs (without any URL-encoding) - * to append to the URL. - * - 'fragment': A fragment identifier (named anchor) to append to the URL. - * Do not include the leading '#' character. - * - 'attributes': An associative array of HTML attributes that will be - * added to the anchor tag if you use the \Drupal\Core\Link class to make - * the link. - * - * @return static - * A new Url object. - */ - public static function fromExternalUrl(string $external_url, $options = []): Url { - $url = new static($external_url, [], $options); - $url->external = TRUE; - $url->setOption('external', TRUE); - $url->setUnrouted(); - return $url; - } - /** * Create a new Url object for entity URIs. * diff --git a/core/modules/image/src/EventSubscriber/ImageDerivativeSubscriber.php b/core/modules/image/src/EventSubscriber/ImageDerivativeSubscriber.php index e043e0c487..59b759034c 100644 --- a/core/modules/image/src/EventSubscriber/ImageDerivativeSubscriber.php +++ b/core/modules/image/src/EventSubscriber/ImageDerivativeSubscriber.php @@ -380,22 +380,18 @@ public function resolveDerivativeImageUrl(ImageProcessEvent $event): void { // to the actual file path, this avoids bootstrapping PHP once the files are // built. if ($clean_urls === FALSE && $this->streamWrapperManager->getScheme($derivative_uri) == 'public' && !file_exists($derivative_uri)) { - $directory_path = $this->streamWrapperManager->getViaUri($derivative_uri)->getDirectoryPath(); - $pipeline->setVariable('derivativeImageUrl', Url::fromUri( - 'base:' . $directory_path . '/' . $this->streamWrapperManager->getTarget($derivative_uri), [ - 'absolute' => TRUE, - 'query' => $token_query, - ]) - ); - return; + $validated_uri = 'base:' . $this->streamWrapperManager->getViaUri($derivative_uri)->getDirectoryPath() . '/' . $this->streamWrapperManager->getTarget($derivative_uri); + } + else { + // Using clean URLs. + $validated_uri = file_create_url($derivative_uri); } - $file_url = Url::fromExternalUrl( - file_create_url($derivative_uri), [ + $pipeline->setVariable('derivativeImageUrl', Url::fromUri($validated_uri, [ + 'absolute' => TRUE, 'query' => $token_query, - ] + ]) ); - $pipeline->setVariable('derivativeImageUrl', $file_url); } /**