Validate JSON returned from Wikidata's sparql endpoint, throw an
exception if it is invalid
This commit is contained in:
@@ -436,6 +436,10 @@ final class NodaWikidataFetcher {
|
|||||||
$url = 'https://query.wikidata.org/sparql?query=' . urlencode($sparqlQuery);
|
$url = 'https://query.wikidata.org/sparql?query=' . urlencode($sparqlQuery);
|
||||||
$result = MD_STD::runCurl($url, 100000000, self::WIKIDATA_FETCH_HEADERS);
|
$result = MD_STD::runCurl($url, 100000000, self::WIKIDATA_FETCH_HEADERS);
|
||||||
|
|
||||||
|
if (json_validate($result) === false) {
|
||||||
|
throw new MDhttpFailedException("Failed to run SPARQL query");
|
||||||
|
}
|
||||||
|
|
||||||
return json_decode($result, true);
|
return json_decode($result, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user