Merge pull request #4939 from astifter/better_curl_error_during_install
Better curl error during install.
This commit is contained in:
commit
66e5586d21
|
@ -9,6 +9,7 @@ include/jquery-1.4.2.min.js
|
||||||
favicon.*
|
favicon.*
|
||||||
home.html
|
home.html
|
||||||
addon
|
addon
|
||||||
|
*.orig
|
||||||
*~
|
*~
|
||||||
robots.txt
|
robots.txt
|
||||||
|
|
||||||
|
@ -57,4 +58,4 @@ venv/
|
||||||
/view/asset
|
/view/asset
|
||||||
|
|
||||||
#ignore config files from JetBrains
|
#ignore config files from JetBrains
|
||||||
/.idea
|
/.idea
|
||||||
|
|
|
@ -303,12 +303,13 @@ function install_content(App $a) {
|
||||||
* required : boolean
|
* required : boolean
|
||||||
* help : string optional
|
* help : string optional
|
||||||
*/
|
*/
|
||||||
function check_add(&$checks, $title, $status, $required, $help) {
|
function check_add(&$checks, $title, $status, $required, $help, $error_msg = "") {
|
||||||
$checks[] = [
|
$checks[] = [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'required' => $required,
|
'required' => $required,
|
||||||
'help' => $help,
|
'help' => $help,
|
||||||
|
'error_msg' => $error_msg,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,18 +490,24 @@ function check_smarty3(&$checks) {
|
||||||
function check_htaccess(&$checks) {
|
function check_htaccess(&$checks) {
|
||||||
$status = true;
|
$status = true;
|
||||||
$help = "";
|
$help = "";
|
||||||
|
$error_msg = "";
|
||||||
if (function_exists('curl_init')) {
|
if (function_exists('curl_init')) {
|
||||||
$test = Network::fetchUrl(System::baseUrl()."/install/testrewrite");
|
$test = Network::fetchUrlFull(System::baseUrl()."/install/testrewrite");
|
||||||
|
|
||||||
if ($test != "ok") {
|
$url = normalise_link(System::baseUrl()."/install/testrewrite");
|
||||||
$test = Network::fetchUrl(normalise_link(System::baseUrl()."/install/testrewrite"));
|
if ($test['body'] != "ok") {
|
||||||
|
$test = Network::fetchUrlFull($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($test != "ok") {
|
if ($test['body'] != "ok") {
|
||||||
$status = false;
|
$status = false;
|
||||||
$help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.');
|
$help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.');
|
||||||
|
$error_msg = [];
|
||||||
|
$error_msg['head'] = L10n::t('Error message from Curl when fetching');
|
||||||
|
$error_msg['url'] = $test['redirect_url'];
|
||||||
|
$error_msg['msg'] = $test['error'];
|
||||||
}
|
}
|
||||||
check_add($checks, L10n::t('Url rewrite is working'), $status, true, $help);
|
check_add($checks, L10n::t('Url rewrite is working'), $status, true, $help, $error_msg);
|
||||||
} else {
|
} else {
|
||||||
// cannot check modrewrite if libcurl is not installed
|
// cannot check modrewrite if libcurl is not installed
|
||||||
/// @TODO Maybe issue warning here?
|
/// @TODO Maybe issue warning here?
|
||||||
|
|
|
@ -36,7 +36,30 @@ class Network
|
||||||
*/
|
*/
|
||||||
public static function fetchUrl($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = 0)
|
public static function fetchUrl($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = 0)
|
||||||
{
|
{
|
||||||
$ret = self::curl(
|
$ret = fetchUrlFull($url, $binary, $redirects, $timeout, $accept_content, $cookiejar);
|
||||||
|
|
||||||
|
return $ret['body'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Curl wrapper with array of return values.
|
||||||
|
*
|
||||||
|
* Inner workings and parameters are the same as @ref fetchUrl but returns an array with
|
||||||
|
* all the information collected during the fetch.
|
||||||
|
*
|
||||||
|
* @param string $url URL to fetch
|
||||||
|
* @param boolean $binary default false
|
||||||
|
* TRUE if asked to return binary results (file download)
|
||||||
|
* @param integer $redirects The recursion counter for internal use - default 0
|
||||||
|
* @param integer $timeout Timeout in seconds, default system config value or 60 seconds
|
||||||
|
* @param string $accept_content supply Accept: header with 'accept_content' as the value
|
||||||
|
* @param string $cookiejar Path to cookie jar file
|
||||||
|
*
|
||||||
|
* @return array With all relevant information, 'body' contains the actual fetched content.
|
||||||
|
*/
|
||||||
|
public static function fetchUrlFull($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = 0)
|
||||||
|
{
|
||||||
|
return self::curl(
|
||||||
$url,
|
$url,
|
||||||
$binary,
|
$binary,
|
||||||
$redirects,
|
$redirects,
|
||||||
|
@ -45,8 +68,6 @@ class Network
|
||||||
'cookiejar'=>$cookiejar
|
'cookiejar'=>$cookiejar
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return($ret['body']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,6 +32,9 @@ td.help {
|
||||||
td.help blockquote {
|
td.help blockquote {
|
||||||
margin-left: 60px;
|
margin-left: 60px;
|
||||||
}
|
}
|
||||||
|
.error_header {
|
||||||
|
margin-left: 60px;
|
||||||
|
}
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
margin: 2em 0;
|
margin: 2em 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,13 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td><td>{{if $check.required}}(required){{/if}}</td></tr>
|
</td><td>{{if $check.required}}(required){{/if}}</td></tr>
|
||||||
{{if $check.help}}
|
{{if $check.help}}
|
||||||
<tr><td class="help" colspan="3"><blockquote>{{$check.help}}</blockquote></td></tr>
|
<tr><td class="help" colspan="3">
|
||||||
|
<blockquote>{{$check.help}}</blockquote>
|
||||||
|
{{if $check.error_msg}}
|
||||||
|
<div class="error_header"><b>{{$check.error_msg.head}}</br><a href="{{$check.error_msg.url}}">{{$check.error_msg.url}}</a></b></div>
|
||||||
|
<blockquote>{{$check.error_msg.msg}}</blockquote>
|
||||||
|
{{/if}}
|
||||||
|
</td></tr>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user