Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
Update Language Files
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Update Language Files
Commits
1db12139
Commit
1db12139
authored
1 year ago
by
bgm
Committed by
bgm
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixes
#12
: do not save empty files if the http request failed
parent
0ad465df
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!4
Fixes #12: do not save empty files if the http request failed
Pipeline
#2013
passed
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Uplang/Utils.php
+29
-5
29 additions, 5 deletions
CRM/Uplang/Utils.php
with
29 additions
and
5 deletions
CRM/Uplang/Utils.php
+
29
−
5
View file @
1db12139
...
...
@@ -139,16 +139,40 @@ class CRM_Uplang_Utils {
}
$client
=
new
GuzzleHttp\Client
();
$response
=
$client
->
request
(
'GET'
,
$remoteURL
,
[
'sink'
=>
$localFile
,
'timeout'
=>
5
,
'http_errors'
=>
FALSE
]);
try
{
$response
=
$client
->
request
(
'GET'
,
$remoteURL
,
[
'sink'
=>
$localFile
,
'timeout'
=>
5
]);
}
catch
(
\GuzzleHttp\Exception\ClientException
$e
)
{
// issue#12 sink will sometimes save a text file with the error
unlink
(
$localFile
);
// Log an appropriate error that might help debugging
if
(
$e
->
hasResponse
())
{
if
(
$e
->
getResponse
()
->
getStatusCode
()
==
404
)
{
// 404 is normal for non-reviewed extensions
\Civi
::
log
()
->
info
(
'Update Language: Guzzle error '
.
$e
->
getResponse
()
->
getStatusCode
()
.
': '
.
$e
->
getResponse
()
->
getReasonPhrase
()
.
' on URL: '
.
$remoteURL
);
}
else
{
\Civi
::
log
()
->
error
(
'Update Language: Guzzle error '
.
$e
->
getResponse
()
->
getStatusCode
()
.
': '
.
$e
->
getResponse
()
->
getReasonPhrase
()
.
' on URL: '
.
$remoteURL
);
}
}
else
{
\Civi
::
log
()
->
error
(
'Update Language: Guzzle unknown error: '
.
$e
->
getMessage
()
.
' on URL: '
.
$remoteURL
);
}
return
FALSE
;
}
if
(
$response
->
getStatusCode
()
!==
200
)
{
\Civi
::
log
()
->
warning
(
$response
->
getStatusCode
()
.
': '
.
$response
->
getReasonPhrase
()
.
'
: '
.
$remoteURL
);
\Civi
::
log
()
->
error
(
'Update Language: Guzzle unknown error: '
.
$e
->
getStatusCode
()
.
' on URL
: '
.
$remoteURL
);
return
FALSE
;
}
if
((
$response
->
getStatusCode
()
===
200
)
&&
file_exists
(
$localFile
))
{
return
TRUE
;
if
(
!
file_exists
(
$localFile
))
{
\Civi
::
log
()
->
error
(
'Update Language: download was succesful but the local file was not found: '
.
$localFile
);
return
FALSE
;
}
return
FALS
E
;
return
TRU
E
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment