Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dashboardnews 504 Gateway Time-out #4734

Merged
merged 2 commits into from
Feb 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/Controllers/Async.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,27 @@ public function dashboardnews(Silex\Application $app, Request $request)
base64_encode($hostname)
);

// Define guzzle options
$guzzleOptions['config']['curl'] = array();
$curlOptions = &$guzzleOptions['config']['curl'];

// Options valid if using a proxy
if ($app['config']->get('general/httpProxy')) {
$curlOptions = array(
'CURLOPT_PROXY' => $app['config']->get('general/httpProxy/host'),
'CURLOPT_PROXYTYPE' => 'CURLPROXY_HTTP',
'CURLOPT_PROXYUSERPWD' => $app['config']->get('general/httpProxy/user') . ':' .
$app['config']->get('general/httpProxy/password')
);
$curlOptions[CURLOPT_PROXY] = $app['config']->get('general/httpProxy/host');
$curlOptions[CURLOPT_PROXYTYPE] = CURLPROXY_HTTP;
$curlOptions[CURLOPT_PROXYUSERPWD] = $app['config']->get('general/httpProxy/user') . ':' .
$app['config']->get('general/httpProxy/password')
;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can keep the array, only the ' needs to go on the contants

}

// Standard option(s)
$curlOptions['CURLOPT_CONNECTTIMEOUT'] = 5;
$curlOptions[CURLOPT_CONNECTTIMEOUT] = 5;

try {
if ($app['deprecated.php']) {
$fetchedNewsData = $app['guzzle.client']->get($url, null, $curlOptions)->send()->getBody(true);
$fetchedNewsData = $app['guzzle.client']->get($url, $guzzleOptions)->send()->getBody(true);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, as it is for Guzzle3 and has the function signature:

public function get($uri = null, $headers = null, $options = array())

$fetchedNewsData = $app['guzzle.client']->get($url, array(), $curlOptions)->getBody(true);
$fetchedNewsData = $app['guzzle.client']->get($url, $guzzleOptions)->getBody(true);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is correct 👍


$fetchedNewsItems = json_decode($fetchedNewsData);
Expand Down