Validate JSON returned from Wikidata's sparql endpoint, throw an

exception if it is invalid
This commit is contained in:
2025-07-08 17:38:34 +02:00
parent 119f216907
commit 1798e29186

View File

@@ -436,6 +436,10 @@ final class NodaWikidataFetcher {
$url = 'https://query.wikidata.org/sparql?query=' . urlencode($sparqlQuery);
$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);
}