Merge pull request #16160 from owncloud/issue-15924-php-notice-empty-path-pathinfo

Do not run method when the path is empty
This commit is contained in:
Morris Jobke 2015-05-08 09:49:51 +02:00
commit 1fbf9c3d71
2 changed files with 15 additions and 1 deletions

View File

@ -326,6 +326,9 @@ class Storage {
*/
public static function getVersions($uid, $filename, $userFullPath = '') {
$versions = array();
if ($filename === '') {
return $versions;
}
// fetch for old versions
$view = new \OC\Files\View('/' . $uid . '/');

View File

@ -411,7 +411,7 @@ class Test_Files_Versioning extends \Test\TestCase {
// execute copy hook of versions app
$versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '/subfolder/test.txt');
$this->assertSame(2, count($versions));
$this->assertCount(2, $versions);
foreach ($versions as $version) {
$this->assertSame('/subfolder/test.txt', $version['path']);
@ -422,6 +422,17 @@ class Test_Files_Versioning extends \Test\TestCase {
$this->rootView->deleteAll(self::USERS_VERSIONS_ROOT . '/subfolder');
}
/**
* test if we find all versions and if the versions array contain
* the correct 'path' and 'name'
*/
public function testGetVersionsEmptyFile() {
// execute copy hook of versions app
$versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '');
$this->assertCount(0, $versions);
}
public function testRestoreSameStorage() {
\OC\Files\Filesystem::mkdir('sub');
$this->doTestRestore();