From 52a90d669cd728f77ad041e7bba75c1ac8b45848 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Tue, 14 Dec 2021 15:40:07 +0100 Subject: [PATCH] Validate geonames and TGN IDs fetched from Wikidata --- src/NodaWikidataFetcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NodaWikidataFetcher.php b/src/NodaWikidataFetcher.php index 5fc270c..94e847c 100644 --- a/src/NodaWikidataFetcher.php +++ b/src/NodaWikidataFetcher.php @@ -1102,8 +1102,8 @@ final class NodaWikidataFetcher { $currentPlaceResult->close(); unset($currentPlaceResult); - if (isset($data['claims']['P1566'])) $geonames_id = $data['claims']['P1566'][0]['mainsnak']['datavalue']['value']; - if (isset($data['claims']['P1667'])) $tgn_id = $data['claims']['P1667'][0]['mainsnak']['datavalue']['value']; + if (isset($data['claims']['P1566'])) $geonames_id = filter_var($data['claims']['P1566'][0]['mainsnak']['datavalue']['value'], FILTER_VALIDATE_INT); + if (isset($data['claims']['P1667'])) $tgn_id = filter_var($data['claims']['P1667'][0]['mainsnak']['datavalue']['value'], FILTER_VALIDATE_INT); $nodaLinks = [ "wikidata" => $wikidata_id,