diff --git a/src/NodaWikidataFetcher.php b/src/NodaWikidataFetcher.php index 31d35a6..a9fcab4 100644 --- a/src/NodaWikidataFetcher.php +++ b/src/NodaWikidataFetcher.php @@ -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);