Merge pull request #15506 from rullzer/core_apps_oc_log2ocp_util

Move core apps from OC_Log::write to OCP\Util
This commit is contained in:
Morris Jobke 2015-07-01 08:53:16 +02:00
commit 044d2ece07
12 changed files with 33 additions and 33 deletions

View file

@ -124,10 +124,10 @@ class OC_Mount_Config {
self::addStorageIdToConfig($data['user']);
$user = \OC::$server->getUserManager()->get($data['user']);
if (!$user) {
\OC_Log::write(
\OCP\Util::writeLog(
'files_external',
'Cannot init external mount points for non-existant user "' . $data['user'] . '".',
\OC_Log::WARN
\OCP\Util::WARN
);
return;
}

View file

@ -27,7 +27,7 @@ OCP\JSON::checkAppEnabled('files_sharing');
if(!isset($_GET['t'])){
\OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
\OCP\Util::writeLog('core-preview', 'No token parameter was passed', \OCP\Util::DEBUG);
exit;
}

View file

@ -36,20 +36,20 @@ $keepAspect = array_key_exists('a', $_GET) ? true : false;
if($token === ''){
\OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
\OCP\Util::writeLog('core-preview', 'No token parameter was passed', \OCP\Util::DEBUG);
exit;
}
$linkedItem = \OCP\Share::getShareByToken($token);
if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) {
\OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
\OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
\OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
exit;
}
if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
\OC_Response::setStatus(\OC_Response::STATUS_INTERNAL_SERVER_ERROR);
\OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OC_Log::WARN);
\OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN);
exit;
}
@ -77,7 +77,7 @@ if($linkedItem['item_type'] === 'folder') {
$isValid = \OC\Files\Filesystem::isValidPath($file);
if(!$isValid) {
\OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . \OC::$server->getRequest()->getRemoteAddress() . '")', \OC_Log::WARN);
\OCP\Util::writeLog('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . \OC::$server->getRequest()->getRemoteAddress() . '")', \OCP\Util::WARN);
exit;
}
$sharedFile = \OC\Files\Filesystem::normalizePath($file);
@ -96,7 +96,7 @@ if(substr($path, 0, 1) === '/') {
if($maxX === 0 || $maxY === 0) {
\OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
\OCP\Util::writeLog('core-preview', 'x and/or y set to 0', \OCP\Util::DEBUG);
exit;
}
@ -113,5 +113,5 @@ try{
$preview->showPreview();
} catch (\Exception $e) {
\OC_Response::setStatus(\OC_Response::STATUS_INTERNAL_SERVER_ERROR);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::DEBUG);
}

View file

@ -55,13 +55,13 @@ class Helper {
$linkItem = \OCP\Share::getShareByToken($token, !$password);
if($linkItem === false || ($linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder')) {
\OC_Response::setStatus(404);
\OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
\OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
exit;
}
if(!isset($linkItem['uid_owner']) || !isset($linkItem['file_source'])) {
\OC_Response::setStatus(500);
\OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OC_Log::WARN);
\OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN);
exit;
}

View file

@ -64,7 +64,7 @@ foreach ($list as $file) {
OCA\Files_Trashbin\Trashbin::delete($filename, \OCP\User::getUser(), $timestamp);
if (OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) {
$error[] = $filename;
OC_Log::write('trashbin','can\'t delete ' . $filename . ' permanently.', OC_Log::ERROR);
\OCP\Util::writeLog('trashbin','can\'t delete ' . $filename . ' permanently.', \OCP\Util::ERROR);
}
// only list deleted files if not deleting everything
else if (!$deleteAll) {

View file

@ -35,13 +35,13 @@ $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] :
if($file === '') {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
\OCP\Util::writeLog('core-preview', 'No file parameter was passed', \OCP\Util::DEBUG);
exit;
}
if($maxX === 0 || $maxY === 0) {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
\OCP\Util::writeLog('core-preview', 'x and/or y set to 0', \OCP\Util::DEBUG);
exit;
}
@ -71,5 +71,5 @@ try{
$preview->showPreview();
}catch(\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::DEBUG);
}

View file

@ -70,7 +70,7 @@ foreach ($list as $file) {
if ( !OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp) ) {
$error[] = $filename;
OC_Log::write('trashbin', 'can\'t restore ' . $filename, OC_Log::ERROR);
\OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, \OCP\Util::ERROR);
} else {
$success[$i]['filename'] = $file;
$success[$i]['timestamp'] = $timestamp;

View file

@ -160,7 +160,7 @@ class Trashbin {
$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
$result = $query->execute(array($ownerFilename, $timestamp, $ownerLocation, $owner));
if (!$result) {
\OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated for the files owner', \OC_log::ERROR);
\OCP\Util::writeLog('files_trashbin', 'trash bin database couldn\'t be updated for the files owner', \OC_log::ERROR);
}
}
}
@ -216,7 +216,7 @@ class Trashbin {
if ($trashStorage->file_exists($trashInternalPath)) {
$trashStorage->unlink($trashInternalPath);
}
\OC_Log::write('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR);
\OCP\Util::writeLog('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR);
}
if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort
@ -231,7 +231,7 @@ class Trashbin {
$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
$result = $query->execute(array($filename, $timestamp, $location, $user));
if (!$result) {
\OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
\OCP\Util::writeLog('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
}
\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', array('filePath' => \OC\Files\Filesystem::normalizePath($file_path),
'trashPath' => \OC\Files\Filesystem::normalizePath($filename . '.d' . $timestamp)));
@ -358,7 +358,7 @@ class Trashbin {
if ($timestamp) {
$location = self::getLocation($user, $filename, $timestamp);
if ($location === false) {
\OC_Log::write('files_trashbin', 'trash bin database inconsistent!', \OC_Log::ERROR);
\OCP\Util::writeLog('files_trashbin', 'trash bin database inconsistent!', \OCP\Util::ERROR);
} else {
// if location no longer exists, restore file in the root directory
if ($location !== '/' &&
@ -675,7 +675,7 @@ class Trashbin {
foreach ($files as $file) {
if ($availableSpace < 0) {
$tmp = self::delete($file['name'], $user, $file['mtime']);
\OC_Log::write('files_trashbin', 'remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', \OC_log::INFO);
\OCP\Util::writeLog('files_trashbin', 'remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', \OC_log::INFO);
$availableSpace += $tmp;
$size += $tmp;
} else {
@ -704,7 +704,7 @@ class Trashbin {
if ($timestamp <= $limit) {
$count++;
$size += self::delete($filename, $user, $timestamp);
\OC_Log::write('files_trashbin', 'remove "' . $filename . '" from trash bin because it is older than ' . $retention_obligation, \OC_log::INFO);
\OCP\Util::writeLog('files_trashbin', 'remove "' . $filename . '" from trash bin because it is older than ' . $retention_obligation, \OCP\Util::INFO);
} else {
break;
}

View file

@ -33,13 +33,13 @@ $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] :
if($file === '' && $version === '') {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('versions-preview', 'No file parameter was passed', \OC_Log::DEBUG);
\OCP\Util::writeLog('versions-preview', 'No file parameter was passed', \OCP\Util::DEBUG);
exit;
}
if($maxX === 0 || $maxY === 0) {
\OC_Response::setStatus(400); //400 Bad Request
\OC_Log::write('versions-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
\OCP\Util::writeLog('versions-preview', 'x and/or y set to 0', \OCP\Util::DEBUG);
exit;
}
@ -55,5 +55,5 @@ try {
$preview->showPreview();
}catch(\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::DEBUG);
}

View file

@ -63,7 +63,7 @@ class Groups{
// Validate name
$groupid = isset($_POST['groupid']) ? $_POST['groupid'] : '';
if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $groupid ) || empty($groupid)){
\OC_Log::write('provisioning_api', 'Attempt made to create group using invalid characters.', \OC_Log::ERROR);
\OCP\Util::writeLog('provisioning_api', 'Attempt made to create group using invalid characters.', \OCP\Util::ERROR);
return new OC_OCS_Result(null, 101, 'Invalid group name');
}
// Check if it exists

View file

@ -48,15 +48,15 @@ class Users {
$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$password = isset($_POST['password']) ? $_POST['password'] : null;
if(OC_User::userExists($userId)) {
\OC_Log::write('ocs_api', 'Failed addUser attempt: User already exists.', \OC_Log::ERROR);
\OCP\Util::writeLog('ocs_api', 'Failed addUser attempt: User already exists.', \OCP\Util::ERROR);
return new OC_OCS_Result(null, 102, 'User already exists');
} else {
try {
OC_User::createUser($userId, $password);
\OC_Log::write('ocs_api', 'Successful addUser call with userid: '.$_POST['userid'], \OC_Log::INFO);
\OCP\Util::writeLog('ocs_api', 'Successful addUser call with userid: '.$_POST['userid'], \OCP\Util::INFO);
return new OC_OCS_Result(null, 100);
} catch (\Exception $e) {
\OC_Log::write('ocs_api', 'Failed addUser attempt with exception: '.$e->getMessage(), \OC_Log::ERROR);
\OCP\Util::writeLog('ocs_api', 'Failed addUser attempt with exception: '.$e->getMessage(), \OCP\Util::ERROR);
return new OC_OCS_Result(null, 101, 'Bad request');
}
}

View file

@ -34,27 +34,27 @@ class OC_USER_WEBDAVAUTH extends OC_User_Backend implements \OCP\IUserBackend {
public function deleteUser($uid) {
// Can't delete user
OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to delete users from web frontend using WebDAV user backend', 3);
OCP\Util::writeLog('OC_USER_WEBDAVAUTH', 'Not possible to delete users from web frontend using WebDAV user backend', 3);
return false;
}
public function setPassword ( $uid, $password ) {
// We can't change user password
OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to change password for users from web frontend using WebDAV user backend', 3);
OCP\Util::writeLog('OC_USER_WEBDAVAUTH', 'Not possible to change password for users from web frontend using WebDAV user backend', 3);
return false;
}
public function checkPassword( $uid, $password ) {
$arr = explode('://', $this->webdavauth_url, 2);
if( ! isset($arr) OR count($arr) !== 2) {
OC_Log::write('OC_USER_WEBDAVAUTH', 'Invalid Url: "'.$this->webdavauth_url.'" ', 3);
OCP\Util::writeLog('OC_USER_WEBDAVAUTH', 'Invalid Url: "'.$this->webdavauth_url.'" ', 3);
return false;
}
list($webdavauth_protocol, $webdavauth_url_path) = $arr;
$url= $webdavauth_protocol.'://'.urlencode($uid).':'.urlencode($password).'@'.$webdavauth_url_path;
$headers = get_headers($url);
if($headers==false) {
OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to connect to WebDAV Url: "'.$webdavauth_protocol.'://'.$webdavauth_url_path.'" ', 3);
OCP\Util::writeLog('OC_USER_WEBDAVAUTH', 'Not possible to connect to WebDAV Url: "'.$webdavauth_protocol.'://'.$webdavauth_url_path.'" ', 3);
return false;
}