Skip to content

Commit eda2545

Browse files
authored
Merge pull request #6 from appleple/fix/auth-file-path-env
Fix/auth file path env
2 parents 109d5e0 + a205beb commit eda2545

14 files changed

Lines changed: 287 additions & 32709 deletions

File tree

app/.env.sample

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# トークンファイルの保存先ディレクトリ
2-
# 未設定時はドキュメントルートを使用
1+
# トークンファイルの保存先ファイルパス(絶対パス)
2+
# 未設定時は <a-blog cmsルート>/private/zoho_tokens.csv を使用
33
ZOHO_TOKEN_PERSISTENCE_PATH=
44

5-
# Zoho SDK ログの出力先ファイルパス
6-
# 未設定時はドキュメントルートにphp_zoho_sdk.logが出力
5+
# Zoho SDK ログの出力先ファイルパス(絶対パス)
6+
# 未設定時は <a-blog cmsルート>/private/php_zoho_sdk.log を使用
77
ZOHO_LOGGER_FILE_PATH=
88

99
# Zoho API レスポンスのキャッシュ有効期間(秒)

app/POST/Zoho/OAuth2.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ public function post()
4747
}
4848
else {
4949
AcmsLogger::error('【Zoho plugin】OAuth2認証のためのパラメータが不足しています。');
50-
return null;
50+
$this->addError('クライアントID、クライアントシークレットを入力してください。');
51+
return $this->Post;
5152
}
5253

53-
$this->Post;
54+
return $this->Post;
5455
}
5556
}

app/Services/Zoho/Client.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ class Client
5656

5757
public function __construct()
5858
{
59-
$documentRoot = $_SERVER['DOCUMENT_ROOT'] ?? '';
60-
$this->loggerFilePath = env('ZOHO_LOGGER_FILE_PATH', $documentRoot . '/' . $this->loggerFilePath);
61-
$this->tokenPresistencePath = env('ZOHO_TOKEN_PERSISTENCE_PATH', $documentRoot);
59+
$scriptDir = defined('SCRIPT_DIR') ? SCRIPT_DIR : ($_SERVER['DOCUMENT_ROOT'] ?? '');
60+
$defaultTokenPath = $scriptDir . 'private/zoho_tokens.csv';
61+
$defaultLogPath = $scriptDir . 'private/' . $this->loggerFilePath;
6262

63-
if (empty($this->tokenPresistencePath)) {
64-
AcmsLogger::warning('【Zoho plugin】環境変数 ZOHO_TOKEN_PERSISTENCE_PATH が設定されていません。');
65-
return;
66-
}
63+
$this->loggerFilePath = env('ZOHO_LOGGER_FILE_PATH', $defaultLogPath);
64+
$tokenPersistencePath = env('ZOHO_TOKEN_PERSISTENCE_PATH', '');
65+
$this->tokenPresistencePath = $tokenPersistencePath !== '' ? $tokenPersistencePath : $defaultTokenPath;
6766

6867
$this->store = new CustomFileStore($this->tokenPresistencePath);
6968
}

0 commit comments

Comments
 (0)