summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-05-08 09:49:51 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-05-08 09:49:51 +0200
commit1fbf9c3d7150c8bd5a1b2dbef7a0dd6f663dbc3a (patch)
treef4955baaff04cf5668e826eab7ca81cbbcd8eba6
parent0577691631336b46c2d8ea12158f82692f5acc18 (diff)
parent2b092f2e9339693f2894a2f056383f1623fad797 (diff)
downloadnextcloud-server-1fbf9c3d7150c8bd5a1b2dbef7a0dd6f663dbc3a.tar.gz
nextcloud-server-1fbf9c3d7150c8bd5a1b2dbef7a0dd6f663dbc3a.zip
Merge pull request #16160 from owncloud/issue-15924-php-notice-empty-path-pathinfo
Do not run method when the path is empty
-rw-r--r--apps/files_versions/lib/storage.php3
-rw-r--r--apps/files_versions/tests/versions.php13
2 files changed, 15 insertions, 1 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 4a5b47d2c2b..f98b134cff2 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -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 . '/');
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index 5ea6d9ee5b9..febde951411 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -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();