Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 298337

Move StreamWrappers from strings to URL objects

$
0
0

Problem/Motivation

StreamWrapper's currently deal with static strings for URLs which means they're not opted in to any cacheability information system, even though URLs can have cacheability information as outlined in #3358113: Allow StreamWrapper's to provide cacheability metadata.

Additionally most StreamWrappers internally already work with a Url which is then converted to a string, so we have the information but are throwing it away.

This issue probably also partially fixes #2867355: file_create_url() causes LogicException when used with certain stream wrappers or at least has a conflicting solution: the referenced issue implements getUrl as a protected method.

Steps to reproduce

Proposed resolution

Introduce getUrl to StreamWrapper so that it provides normal URL objects which contain routing information that can be provided with cacheability information. Additionally this benefits from improvements when URL objects themselves get cacheability information (e.g. because they're an external time-restricted link).

We specifically do not use GeneratedUrl because it contains less information than a Url object, specifically we make assumptions about how a URL should be consumed (absolute/relative) which other systems can better judge. We can see this in action by the FileUrlGenerator breaking apart output of the stream wrapper and converting it to a Url itself.

Remaining tasks

In a follow-up that will land in a next major version:

  • Deprecate StreamWrapperGetUrlInterface
  • Implement getUrl and extend StreamWrapperGetUrlInterface in StreamWrapperInterface

In a follow-up that will land in a next major version + 1:

  • Remove StreamWrapperGetUrlInterface

User interface changes

API changes

  • Introduce StreamWrapperGetUrlInterface which contains the getUrl method.
  • All concrete StreamWrappers in Drupal core implement StreamWrapperGetUrlInterface
  • Deprecate StreamWrapperInterface::getExternalUrl
  • FileUrlGenerator throws a deprecation error in case StreamWrapperGetUrlInterface is not implemented for a StreamWrapperInterface implementation

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 298337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>