Skip to content
Snippets Groups Projects
Commit 314b2e62 authored by bgm's avatar bgm Committed by bgm
Browse files

Do not create an empty file if no translation (not required anymore since we...

Do not create an empty file if no translation (not required anymore since we do not auto-refresh when some forms are loaded)
parent cd425beb
Branches
Tags
No related merge requests found
Pipeline #1996 passed
......@@ -128,13 +128,10 @@ class CRM_Uplang_Utils {
* @param string $remoteURL URL for this particular file
* @param string $localFile where to store this file locally
*
* @return boolean true if the file was refreshed and is not empty
* @return boolean true if the file was refreshed
* @throws \Exception
*/
public static function downloadFile($remoteURL, $localFile) : bool {
# $delay = strtotime('1 day');
# $l10nFileOutOfDate = ((time() - @filemtime($localFile)) > $delay);
$localeDir = dirname($localFile);
// uplang_fetch() checks the "l10n" directory, but not "l10n/fr_FR/LC_MESSAGES", for example
if (!is_dir($localeDir) && !@mkdir($localeDir, 0775, TRUE)) {
......@@ -145,8 +142,6 @@ class CRM_Uplang_Utils {
$response = $client->request('GET', $remoteURL, ['sink' => $localFile, 'timeout' => 5, 'http_errors' => FALSE]);
if ($response->getStatusCode() !== 200) {
\Civi::log()->warning($response->getStatusCode() . ': ' . $response->getReasonPhrase() . ': ' . $remoteURL);
// reset the file to empty (then will not try to reload until delay is passed)
fclose(fopen($localFile, 'w'));
return FALSE;
}
if (($response->getStatusCode() === 200) && file_exists($localFile)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment