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

Use basename() instead of self implementation #7260

Merged
merged 1 commit into from
Nov 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
4 changes: 2 additions & 2 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function insert($file, array $data) {

$data['path'] = $file;
$data['parent'] = $this->getParentId($file);
$data['name'] = \OC_Util::basename($file);
$data['name'] = basename($file);

list($queryParts, $params) = $this->buildParts($data);
$queryParts[] = '`storage`';
Expand Down Expand Up @@ -551,7 +551,7 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
}

$sql = 'UPDATE `*PREFIX*filecache` SET `storage` = ?, `path` = ?, `path_hash` = ?, `name` = ?, `parent` = ? WHERE `fileid` = ?';
$this->connection->executeQuery($sql, array($targetStorageId, $targetPath, md5($targetPath), \OC_Util::basename($targetPath), $newParentId, $sourceId));
$this->connection->executeQuery($sql, array($targetStorageId, $targetPath, md5($targetPath), basename($targetPath), $newParentId, $sourceId));
$this->connection->commit();
} else {
$this->moveFromCacheFallback($sourceCache, $sourcePath, $targetPath);
Expand Down
10 changes: 0 additions & 10 deletions lib/private/legacy/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1407,16 +1407,6 @@ public static function normalizeUnicode($value) {
return $normalizedValue;
}

/**
* @param boolean|string $file
* @return string
*/
public static function basename($file) {
$file = rtrim($file, '/');
$t = explode('/', $file);
return array_pop($t);
}

/**
* A human readable string is generated based on version and build number
*
Expand Down
18 changes: 0 additions & 18 deletions tests/lib/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,6 @@ function testGetInstanceIdGeneratesValidId() {
$this->assertSame(1, $matchesRegex);
}

/**
* @dataProvider baseNameProvider
*/
public function testBaseName($expected, $file) {
$base = \OC_Util::basename($file);
$this->assertEquals($expected, $base);
}

public function baseNameProvider() {
return array(
array('public_html', '/home/user/public_html/'),
array('public_html', '/home/user/public_html'),
array('', '/'),
array('public_html', 'public_html'),
array('442aa682de2a64db1e010f50e60fd9c9', 'local::C:\Users\ADMINI~1\AppData\Local\Temp\2/442aa682de2a64db1e010f50e60fd9c9/')
);
}

/**
* @dataProvider filenameValidationProvider
*/
Expand Down