Commit c78e09fc authored by Andrew Berry's avatar Andrew Berry
Browse files

Issue #2470047: Fix when dirname() is called before setUrl().

parent 7b79fc7b
Loading
Loading
Loading
Loading
+7 −0
Changes for src/StreamWrapper.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -260,6 +260,13 @@ class StreamWrapper extends \Aws\S3\StreamWrapper implements \DrupalStreamWrappe
   * {@inheritdoc}
   */
  public function dirname($uri = NULL) {
    // drupal_dirname() doesn't call setUri() before calling. That lead our URI
    // to be stuck at the default 's3://'' that is set by
    // file_stream_wrapper_get_instance_by_scheme().
    if ($uri) {
      $this->setUri($uri);
    }

    $s3url = S3Url::factory($uri, $this->config);
    $s3url->normalizePath();
    $pathSegments = $s3url->getPathSegments();