Minor comments and code style fixes - refs BT#16686

pull/3138/head
Sébastien Ducoulombier 6 years ago
parent 393b4d7c3b
commit f4f00d6411
  1. 13
      main/inc/global.inc.php
  2. 8
      main/inc/lib/api.lib.php

@ -82,11 +82,14 @@ api_request_uri();
// Set web proxy environment variables
foreach ([
api_get_configuration_sub_value('proxy_settings/stream_context_create/https/proxy'),
api_get_configuration_sub_value('proxy_settings/stream_context_create/http/proxy'),
api_get_configuration_sub_value('proxy_settings/curl_setopt_array/CURLOPT_PROXY'),
] as $value) {
if ($value && is_string($value)) {
'proxy_settings/stream_context_create/https/proxy',
'proxy_settings/stream_context_create/http/proxy',
'proxy_settings/curl_setopt_array/CURLOPT_PROXY',
] as $path) {
$value = api_get_configuration_sub_value($path);
if (!empty($value) && is_string($value)) {
// libcurl reads environment variable https_proxy: https://curl.haxx.se/libcurl/c/libcurl-env.html
// \GuzzleHttp\Client::configureDefaults reads environment variable HTTPS_PROXY
foreach (['https_proxy', 'http_proxy', 'HTTPS_PROXY', 'HTTP_PROXY'] as $envVar) {
if (false === getenv($envVar)) {
putenv("$envVar=$value");

@ -8654,16 +8654,18 @@ function api_get_configuration_value($variable)
}
/**
* Retreives and return a value in an array tree configuration item
* api_get_configuration_sub_value('a/b/c') returns api_get_configuration_value('a')['b']['c']
* Retreives and returns a value in a hierarchical configuration array
* api_get_configuration_sub_value('a/b/c') returns api_get_configuration_value('a')['b']['c'].
*
* @param string $path the successive array keys, seperated by the separator
* @param mixed $default value to be returned if not found, null by default
* @param string $separator '/' by default
* @param array $array the active configuration array by default
*
* @return mixed the found value or $default
*/
function api_get_configuration_sub_value($path, $default = null, $separator = '/', $array = null) {
function api_get_configuration_sub_value($path, $default = null, $separator = '/', $array = null)
{
$pos = strpos($path, $separator);
if (false === $pos) {
if (is_null($array)) {

Loading…
Cancel
Save