From 9132745631830a2b4e1d4a3566410b48ea3b5663 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sun, 9 Jan 2022 22:19:22 +0100 Subject: [PATCH] Fix bug in time splitter, make code more explicit --- src/NodaTimeSplitter.php | 2 +- src/NodaWikidataFetcher.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NodaTimeSplitter.php b/src/NodaTimeSplitter.php index d13f88d..71b3ef3 100644 --- a/src/NodaTimeSplitter.php +++ b/src/NodaTimeSplitter.php @@ -1016,7 +1016,7 @@ final class NodaTimeSplitter { // Skip 1200-1300 if (!empty(self::attempt_splitting($datum))) return []; - if (strlen($datum) === 9 and substr($datum, 4, 1)) return []; + if (strlen($datum) === 9 and substr($datum, 4, 1) !== '-') return []; if (empty($startEnd = self::check_is_timespan_from_till($datum))) { return []; diff --git a/src/NodaWikidataFetcher.php b/src/NodaWikidataFetcher.php index 0e43480..4e3450a 100644 --- a/src/NodaWikidataFetcher.php +++ b/src/NodaWikidataFetcher.php @@ -1094,7 +1094,7 @@ final class NodaWikidataFetcher { $datafromwiki = MD_STD::runCurl("https://" . urlencode($sprache) . ".wikipedia.org/w/api.php?action=parse&page=" . urlencode($wikilinkterm[$sprache]) . "&prop=text§ion=0&format=json", 10000); $datafromwiki = json_decode($datafromwiki, true)['parse']['text']['*']; - if (!empty($datafromwiki) and $datafromwiki = self::_cleanWikidataInput((string)$datafromwiki)) { + if (!empty($datafromwiki) and !empty($datafromwiki = self::_cleanWikidataInput((string)$datafromwiki))) { $alreadyEntered = $this->enterPlaceDescFromWikidata($currentPlaceResult, $datafromwiki, $wikilink, $lang, $sprache, $onum, $erfasst_von); } @@ -1729,7 +1729,7 @@ final class NodaWikidataFetcher { $birth_date_int = strtotime(substr($inputTime, 1, 4)); if ($birth_date_int) { $birth_date = date("Y", $birth_date_int); - if ($birth_date === date("Y") and $tTime = strtotime($inputTime)) { + if ($birth_date === date("Y") and ($tTime = strtotime($inputTime)) !== false) { $birth_date = date("Y", $tTime); }