#2392559: Remove all uses of file_stream_wrapper_get_* and file_get_stream_wrappers
In this issue, let's remove the functions itself.

file_stream_wrapper_get_class
file_stream_wrapper_get_instance_by_uri
file_stream_wrapper_get_instance_by_scheme
file_get_stream_wrappers

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue priority Normal as the patch removes no longer used, already deprecated, functions
Prioritized changes code already marked for removal by 8.0.0
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rpayanm’s picture

Title: Remove file_stream_wrapper_get_instance_by_uri() » Remove file_stream_wrapper_get_*(), file_get_mimetype() and file_get_stream_wrappers()
Issue summary: View changes
Related issues: -#2363717: Remove usage of file_stream_wrapper_get_instance_by_uri() +#2392559: Remove all uses of file_stream_wrapper_get_* and file_get_stream_wrappers
ianthomas_uk’s picture

Title: Remove file_stream_wrapper_get_*(), file_get_mimetype() and file_get_stream_wrappers() » Remove file_stream_wrapper_get_*() and file_get_stream_wrappers()
mondrake’s picture

Status: Postponed » Active
rpayanm’s picture

Issue summary: View changes
rpayanm’s picture

Status: Active » Needs review
FileSize
4.39 KB

Please review.

mondrake’s picture

Status: Needs review » Needs work

Actually, it looks like some documentation that is in file.inc was not moved to StreamWrapperManagerInterface:

+++ b/core/includes/file.inc
@@ -215,55 +172,6 @@ function file_stream_wrapper_uri_normalize($uri) {
 /**
- * Returns a reference to the stream wrapper class responsible for a given URI.
- *
- * The scheme determines the stream wrapper class that should be
- * used by consulting the stream wrapper registry.
- *
- * @param string $uri
- *   A stream, referenced as "scheme://target".
- *
- * @return \Drupal\Core\StreamWrapper\StreamWrapperInterface|bool
- *   Returns a new stream wrapper object appropriate for the given URI or FALSE
- *   if no registered handler could be found. For example, a URI of
- *   "private://example.txt" would return a new private stream wrapper object
- *   (Drupal\Core\StreamWrapper\PrivateStream).
- *
- * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
- *   Use \Drupal::service('stream_wrapper_manager')->getViaUri().
- */
-function file_stream_wrapper_get_instance_by_uri($uri) {

for ::getViaUri, and

+++ b/core/includes/file.inc
@@ -215,55 +172,6 @@ function file_stream_wrapper_uri_normalize($uri) {
-/**
- * Returns a reference to the stream wrapper class responsible for a scheme.
- *
- * This helper method returns a stream instance using a scheme. That is, the
- * passed string does not contain a "://". For example, "public" is a scheme
- * but "public://" is a URI (stream). This is because the later contains both
- * a scheme and target despite target being empty.
- *
- * Note: the instance URI will be initialized to "scheme://" so that you can
- * make the customary method calls as if you had retrieved an instance by URI.
- *
- * @param string $scheme
- *   If the stream was "public://target", "public" would be the scheme.
- *
- * @return \Drupal\Core\StreamWrapper\StreamWrapperInterface|bool
- *   Returns a new stream wrapper object appropriate for the given $scheme.
- *   For example, for the public scheme a stream wrapper object
- *   (Drupal\Core\StreamWrapper\PublicStream).
- *   FALSE is returned if no registered handler could be found.
- *
- * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
- *   Use \Drupal::service('stream_wrapper_manager')->getViaScheme().
- */
-function file_stream_wrapper_get_instance_by_scheme($scheme) {

for ::getViaScheme

The docs in StreamWrapperManagerInterface is much more bare bone and I wonder if the one in file.inc that we are dropping should be added back there.

rpayanm’s picture

FileSize
2.92 KB
7.32 KB
rpayanm’s picture

Status: Needs work » Needs review
mondrake’s picture

Status: Needs review » Needs work

Thank you @rpayanm!

+++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManagerInterface.php
@@ -113,35 +113,52 @@ public function getNames($filter = StreamWrapperInterface::ALL);
+   * Returns a reference to the stream wrapper class responsible for a given URI.

Nit - over 80 chars

+++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManagerInterface.php
@@ -113,35 +113,52 @@ public function getNames($filter = StreamWrapperInterface::ALL);
+   *   Returns a new stream wrapper object appropriate for the given URI or FALSE

This too

mondrake’s picture

Issue summary: View changes

Added beta evaluation

rpayanm’s picture

+++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManagerInterface.php
@@ -113,35 +113,52 @@ public function getNames($filter = StreamWrapperInterface::ALL);
+   * Returns a reference to the stream wrapper class responsible for a given URI.

Nit - over 80 chars

Please you can suggest a new sentence, my English is no so good and this must be in one line.

mondrake’s picture

:) I'm also not a native :)

Suggestion:

Returns a reference to the stream wrapper class responsible for an URI.

rpayanm’s picture

Status: Needs work » Needs review
FileSize
1.36 KB
7.31 KB

hehe your english is better :)

Here the patch.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Applied the patch and grepped the code base for 'file_stream_wrapper_get' and 'file_get_stream', no results.
Some documentation moved from file.inc to StreamWrapperManagerInterface.

Looks ready to go, RTBC

ianthomas_uk’s picture

"a URI" is better English than "an URI" (assuming everyone says the letters, you could argue for "an URL" because some people pronounce that like "an earl", but I think most people would spell out URI).

rpayanm’s picture

FileSize
759 bytes
7.31 KB

suggestion of @ianthomas_uk

xjm’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for moving the documentation over from the functions and for the beta evaluation.

As a removal of code that was deprecated for 8.0.0 before the beta, this patch is a prioritized change during the beta. Committed and pushed to 8.0.x. Thanks!

  • xjm committed 1aca0e4 on 8.0.x
    Issue #2382859 by rpayanm, mondrake, ianthomas_uk: Remove...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.