Skip to content

Commit 2c80249

Browse files
committed
include path removed, default log location changed
1 parent b92c7ef commit 2c80249

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/crm/utility/Logger.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ class Logger
66

77
public static function writeToFile($msg)
88
{
9-
set_include_path(ZCRMConfigUtil::getConfigValue(APIConstants::APPLICATION_LOGFILE_PATH));
10-
$path = get_include_path();
9+
$path = trim(ZCRMConfigUtil::getConfigValue(APIConstants::APPLICATION_LOGFILE_PATH));
1110
if (!ZCRMConfigUtil::getConfigValue(APIConstants::APPLICATION_LOGFILE_PATH)) {
12-
$path=dirname(__FILE__) ."/../../..";
11+
$path=posix_getpwuid(posix_getuid())["dir"];
1312
}
1413
$filePointer = fopen($path . APIConstants::APPLICATION_LOGFILE_NAME, "a");
1514
if (! $filePointer) {

src/oauth/persistence/ZohoOAuthPersistenceByFile.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,26 @@
1010
class ZohoOAuthPersistenceByFile implements ZohoOAuthPersistenceInterface
1111
{
1212

13-
public function setIncludePath()
13+
public function getTokenPersistencePath()
1414
{
1515
$path = ZohoOAuth::getConfigValue('token_persistence_path');
1616
$path = trim($path);
17-
set_include_path($path);
17+
return $path;
1818
}
1919

2020
public function saveOAuthData($zohoOAuthTokens)
2121
{
2222
try {
2323
self::deleteOAuthTokens($zohoOAuthTokens->getUserEmailId());
24-
self::setIncludePath();
25-
$content = file_get_contents("zcrm_oauthtokens.txt", FILE_USE_INCLUDE_PATH);
24+
$content = file_get_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt" );
2625
if ($content == "") {
2726
$arr = array();
2827
} else {
2928
$arr = unserialize($content);
3029
}
3130
array_push($arr, $zohoOAuthTokens);
3231
$serialized = serialize($arr);
33-
file_put_contents("zcrm_oauthtokens.txt", $serialized, FILE_USE_INCLUDE_PATH);
32+
file_put_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt",$serialized );
3433
} catch (Exception $ex) {
3534
Logger::severe("Exception occured while Saving OAuthTokens to file(file::ZohoOAuthPersistenceByFile)({$ex->getMessage()})\n{$ex}");
3635
throw $ex;
@@ -40,8 +39,7 @@ public function saveOAuthData($zohoOAuthTokens)
4039
public function getOAuthTokens($userEmailId)
4140
{
4241
try {
43-
self::setIncludePath();
44-
$serialized = file_get_contents("zcrm_oauthtokens.txt", FILE_USE_INCLUDE_PATH);
42+
$serialized = file_get_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt" );
4543
if (! isset($serialized) || $serialized == "") {
4644
throw new ZohoOAuthException("No Tokens exist for the given user-identifier,Please generate and try again.");
4745
}
@@ -71,8 +69,7 @@ public function getOAuthTokens($userEmailId)
7169
public function deleteOAuthTokens($userEmailId)
7270
{
7371
try {
74-
self::setIncludePath();
75-
$serialized = file_get_contents("zcrm_oauthtokens.txt", FILE_USE_INCLUDE_PATH);
72+
$serialized = file_get_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt" );
7673
if (! isset($serialized) || $serialized == "") {
7774
return;
7875
}
@@ -90,7 +87,7 @@ public function deleteOAuthTokens($userEmailId)
9087
$arr = array_values(array_filter($arr));
9188
}
9289
$serialized = serialize($arr);
93-
file_put_contents("zcrm_oauthtokens.txt", $serialized, FILE_USE_INCLUDE_PATH);
90+
file_put_contents(self::getTokenPersistencePath()."/zcrm_oauthtokens.txt",$serialized );
9491
} catch (Exception $ex) {
9592
Logger::severe("Exception occured while Saving OAuthTokens to file(file::ZohoOAuthPersistenceByFile)({$ex->getMessage()})\n{$ex}");
9693
throw $ex;

0 commit comments

Comments
 (0)