Skip to content

Commit

Permalink
Merge pull request aws#681 from dstevenson/bugfix/issue-639
Browse files Browse the repository at this point in the history
bugfix(S3/StreamWrapper) Init protocol from passed path. Protocols are
  • Loading branch information
mtdowling committed Jul 9, 2015
2 parents d553ae4 + 6db66f4 commit c5ac2e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/S3/StreamWrapper.php
Expand Up @@ -515,6 +515,9 @@ private function formatKey($key)
*/
public function rename($path_from, $path_to)
{
// PHP will not allow rename across wrapper types, so we can safely
// assume $path_from and $path_to have the same protocol
$this->initProtocol($path_from);
$partsFrom = $this->withPath($path_from);
$partsTo = $this->withPath($path_to);
$this->clearCacheKey($path_from);
Expand Down
10 changes: 10 additions & 0 deletions tests/S3/StreamWrapperTest.php
Expand Up @@ -407,6 +407,16 @@ public function testCanDeleteNestedFolderWithRmDir()
$this->assertEquals('/foo/bar/', $entries[1]['request']->getUri()->getPath());
}

/**
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage rename(): Cannot rename a file across wrapper types
*/
public function testRenameEnsuresProtocolsMatch()
{
StreamWrapper::register($this->client, 'baz');
rename('s3://foo/bar', 'baz://qux/quux');
}

/**
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage The Amazon S3 stream wrapper only supports copying objects
Expand Down

0 comments on commit c5ac2e4

Please sign in to comment.