Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable12] Fix for mb strlen #5830

Merged
merged 2 commits into from
Jul 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
$this->connection->beginTransaction();
if ($sourceData['mimetype'] === 'httpd/unix-directory') {
//update all child entries
$sourceLength = strlen($sourcePath);
$sourceLength = mb_strlen($sourcePath);
$query = $this->connection->getQueryBuilder();

$fun = $query->func();
Expand Down
74 changes: 38 additions & 36 deletions tests/lib/Files/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,48 +488,50 @@ function testSearchByQuery() {
, 10, 0, [], $user)));
}

function testMove() {
$file1 = 'folder';
$file2 = 'folder/bar';
$file3 = 'folder/foo';
$file4 = 'folder/foo/1';
$file5 = 'folder/foo/2';
function movePathProvider() {
return [
['folder/foo', 'folder/foobar', ['1', '2']],
['folder/foo', 'foo', ['1', '2']],
['files/Индустрия_Инженерные системы ЦОД', 'files/Индустрия_Инженерные системы ЦОД1', ['1', '2']],
];
}

/**
* @dataProvider movePathProvider
*/
function testMove($sourceFolder, $targetFolder, $children) {
$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
$folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');

$this->cache->put($file1, $folderData);
$this->cache->put($file2, $folderData);
$this->cache->put($file3, $folderData);
$this->cache->put($file4, $data);
$this->cache->put($file5, $data);
// create folders
foreach ([$sourceFolder, $targetFolder] as $current) {
while (strpos($current, '/') > 0) {
$current = dirname($current);
$this->cache->put($current, $folderData);
$this->cache2->put($current, $folderData);
}
}

/* simulate a second user with a different storage id but the same folder structure */
$this->cache2->put($file1, $folderData);
$this->cache2->put($file2, $folderData);
$this->cache2->put($file3, $folderData);
$this->cache2->put($file4, $data);
$this->cache2->put($file5, $data);
$this->cache->put($sourceFolder, $folderData);
$this->cache2->put($sourceFolder, $folderData);
foreach ($children as $child) {
$this->cache->put($sourceFolder . '/' . $child, $data);
$this->cache2->put($sourceFolder . '/' . $child, $data);
}

$this->cache->move('folder/foo', 'folder/foobar');
$this->cache->move($sourceFolder, $targetFolder);

$this->assertFalse($this->cache->inCache('folder/foo'));
$this->assertFalse($this->cache->inCache('folder/foo/1'));
$this->assertFalse($this->cache->inCache('folder/foo/2'));

$this->assertTrue($this->cache->inCache('folder/bar'));
$this->assertTrue($this->cache->inCache('folder/foobar'));
$this->assertTrue($this->cache->inCache('folder/foobar/1'));
$this->assertTrue($this->cache->inCache('folder/foobar/2'));

/* the folder structure of the second user must not change! */
$this->assertTrue($this->cache2->inCache('folder/bar'));
$this->assertTrue($this->cache2->inCache('folder/foo'));
$this->assertTrue($this->cache2->inCache('folder/foo/1'));
$this->assertTrue($this->cache2->inCache('folder/foo/2'));

$this->assertFalse($this->cache2->inCache('folder/foobar'));
$this->assertFalse($this->cache2->inCache('folder/foobar/1'));
$this->assertFalse($this->cache2->inCache('folder/foobar/2'));

$this->assertFalse($this->cache->inCache($sourceFolder));
$this->assertTrue($this->cache2->inCache($sourceFolder));
$this->assertTrue($this->cache->inCache($targetFolder));
$this->assertFalse($this->cache2->inCache($targetFolder));
foreach ($children as $child) {
$this->assertFalse($this->cache->inCache($sourceFolder . '/' . $child));
$this->assertTrue($this->cache2->inCache($sourceFolder . '/' . $child));
$this->assertTrue($this->cache->inCache($targetFolder . '/' . $child));
$this->assertFalse($this->cache2->inCache($targetFolder . '/' . $child));
}
}

function testGetIncomplete() {
Expand Down