Better validate input JSON fetched from Wikipedia
This commit is contained in:
parent
c72ad51dda
commit
4dcd93b947
@ -151,7 +151,11 @@ final class NodaWikidataFetcher {
|
||||
private static function _getCleanedWikipediaSnippet(string $lang, string $title):string {
|
||||
|
||||
$datafromwiki = MD_STD::runCurl(self::_getWikipediaApiLink($lang, $title), 10000);
|
||||
$datafromwiki = strval(json_decode($datafromwiki, true)['parse']['text']['*']);
|
||||
$json_decoded = json_decode($datafromwiki, true);
|
||||
if (empty($json_decoded) || !isset($json_decoded['parse'])) {
|
||||
return '';
|
||||
}
|
||||
$datafromwiki = strval($json_decoded['parse']['text']['*']);
|
||||
|
||||
return self::_cleanWikidataInput($datafromwiki);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user