Skip to content
Snippets Groups Projects
Commit e9b3182e authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '502-quicktips-funktionieren-nicht' into 'development'

Timeout für alle Abfragen aus den Quictips eingeführt (2s)

See merge request !869
parents 6aeb31ec 8dfd91cf
No related branches found
No related tags found
2 merge requests!870Development,!869Timeout für alle Abfragen aus den Quictips eingeführt (2s)
......@@ -172,7 +172,12 @@ class MetaGerSearch extends Controller
# Wikipedia Quicktip
$url = "https://" . APP::getLocale() . ".wikipedia.org/w/api.php?action=opensearch&search=" . urlencode($q) . "&limit=10&namespace=0&format=json&redirects=resolve";
$decodedResponse = json_decode($this->get($url), true);
try{
$content = $this->get($url);
}catch(\ErrorException $e){
$content = "";
}
$decodedResponse = json_decode($content, true);
if (isset($decodedResponse[1][0]) && isset($decodedResponse[2][0]) && isset($decodedResponse[3][0])) {
$quicktip = [];
$firstSummary = $decodedResponse[2][0];
......@@ -261,7 +266,8 @@ class MetaGerSearch extends Controller
public function get($url)
{
return file_get_contents($url);
$ctx = stream_context_create(array('http'=>array('timeout' => 2,)));
return file_get_contents($url, false, $ctx);
}
private function startsWith($haystack, $needle)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment