Dependencies: This patch requires #227232: Support PHP stream wrappers being committed first.

Also see part 2 which depends on this this patch: #517814: File API Stream Wrapper Conversion.

Synopsis
This patch begins introducing stream wrapper support into the File API. drupal_dirname() and drupal_realpath() are added to compensate for some deficiencies in PHP's native stream wrapper support. Calls to dirname() and realpath() are substituted accordingly. drupal_chmod() was also updated with wrapper support.

All three functions are backwards compatible and will work with both normal paths and streams.

Why this is needed
Follow-up patch #517814: File API Stream Wrapper Conversion integrates stream wrappers throughout core and depend on these changes being made to cover the small gaps in PHP's stream wrapper support.

To test this patch
The testing bot will not be able to test this patch until dependencies are committed. In the mean time, you can test this patch locally by applying in the following sequence: #227232: Support PHP stream wrappers, this patch.

Comments

aaron’s picture

subscribing

drewish’s picture

subscribing

drewish’s picture

all in all it looks like a good patch. did a super quick review...

-  $path = dirname($path);
+  $path     = drupal_dirname($path);

odd spacing.

- * Set the permissions on a file or directory.
+ * Sets the permissions on a stream (URI).

This seems a little odd... I think the original is correct but we can specify that the $path can be a stream.

+ * @param int $mode
  *   Integer value for the permissions. Consult PHP chmod() documentation for
  *   more information.

We should really add in a @see to chmod() I think the api.module is smart enough to link that back to PHP's docs.

+function drupal_realpath($uri) {
+

can we ditch these leading new lines?

Again hate canonicalized.

jmstacey’s picture

StatusFileSize
new20.42 KB

odd spacing.

It's actually aligning with the '=' in the previous line. I had to change the line anyway so I thought I'd take the liberty (skimming code is a lot nicer when everything is lined up and not bunched together). Would you like me to remove it nonetheless?

I've made all of the other changes. I've also added @see realpath() and @see dirname().

file_get_mimetype() has also been moved from sister patch #2 now that it is backwards compatible.

Edit: And some type hint removals.

jmstacey’s picture

StatusFileSize
new20.78 KB

Some minor modifications because of upstream changes. Upstream being Drupal 7 Head and #227232: Support PHP stream wrappers.

pwolanin’s picture

Status: Needs work » Closed (duplicate)

for easier development, consolidating all action to #517814: File API Stream Wrapper Conversion