Remove superfluous variable assignments

This commit is contained in:
2022-09-15 21:29:07 +02:00
parent 7c0ad9fa37
commit 5819caff91
12 changed files with 44 additions and 134 deletions

View File

@ -269,15 +269,13 @@ final class NodaWikidataFetcher {
}
$sparqlQueryString = 'SELECT ?id ?idLabel WHERE {
return 'SELECT ?id ?idLabel WHERE {
?id wdt:' . $repoPId . ' "' . $externalId . '".
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}';
return $sparqlQueryString;
}
/**
@ -566,22 +564,25 @@ final class NodaWikidataFetcher {
FROM `persinst`
WHERE `persinst_id` = ?", "i", $persinst_id);
if (!($cinfo = $cergebnis->fetch_row())) {
throw new Exception("There is no actor of ID #" . $persinst_id);
}
$cergebnis->close();
$persinst_kurzinfo = $cinfo[0];
$display_name = $cinfo[1];
// Update persinst table
$updatePersinstStmt = $this->_mysqli_noda->do_prepare("UPDATE `persinst`
SET `persinst_kurzinfo` = ?
WHERE `persinst_id` = ?");
if ($cergebnis->num_rows === 0) {
throw new Exception("There is no actor of ID #" . $persinst_id);
}
$cinfo = $cergebnis->fetch_assoc();
if (!empty($cinfo['persinst_kurzinfo']) and substr($cinfo['persinst_kurzinfo'], 0, 3) !== 'GND') {
if (!empty($persinst_kurzinfo) and substr($persinst_kurzinfo, 0, 3) !== 'GND') {
switch ($this->_retrievalMode) {
case "add":
$newDesc = $cinfo['persinst_kurzinfo'] . PHP_EOL . PHP_EOL . $datafromwiki;
$newDesc = $persinst_kurzinfo . PHP_EOL . PHP_EOL . $datafromwiki;
$updatePersinstStmt->bind_param("si", $newDesc, $persinst_id);
$updatePersinstStmt->execute();
@ -589,7 +590,6 @@ final class NodaWikidataFetcher {
break;
case "keep":
$newDesc = $cinfo['persinst_kurzinfo'];
break;
case "replace":
@ -603,12 +603,12 @@ final class NodaWikidataFetcher {
$tlLoader = new MDTlLoader("wiki_getter_persinst", $preflang);
echo self::generateHTMLHeadForWikidataFetcher($lang);
echo self::generateWikidataFetcherHeader($tlLoader, "", $cinfo['display_name']);
echo self::generateWikidataFetcherHeader($tlLoader, "", $display_name);
echo '
<p class="alert icons iconsAlert">Es gibt schon einen Eintrag im Beschreibungsfeld</p>
<div class="wikiReplaceTTile">
<h3>Bisher vorhanden</h3>
<p>' . nl2br($cinfo['persinst_kurzinfo']) . '</p>
<p>' . nl2br($persinst_kurzinfo) . '</p>
</div>
<div class="wikiReplaceTTile">
<h3>Jetzt gefunden</h3><p>' . $datafromwiki . '</p>
@ -630,8 +630,6 @@ final class NodaWikidataFetcher {
$output = true;
}
$cergebnis->close();
$updatePersinstStmt->close();
// Set link to Wikipedia in noda table
@ -653,7 +651,6 @@ final class NodaWikidataFetcher {
$updatePersinstEditInfoStmt->bind_param("si", $erfasst_von, $persinst_id);
$updatePersinstEditInfoStmt->execute();
$updatePersinstEditInfoStmt->close();
$updatePersinstEditInfoStmt = null;
return $output;
@ -677,7 +674,6 @@ final class NodaWikidataFetcher {
throw new MDmainEntityNotExistentException("Failed to fetch actor information");
}
$result->close();
$result = null;
if ($actor_dates['persinst_geburtsjahr'] === '') {
@ -698,7 +694,6 @@ final class NodaWikidataFetcher {
$updateStmt->bind_param("ii", $birth_date, $persinst_id);
$updateStmt->execute();
$updateStmt->close();
$updateStmt = null;
}
}
@ -718,7 +713,6 @@ final class NodaWikidataFetcher {
$updateStmt->bind_param("ii", $death_date, $persinst_id);
$updateStmt->execute();
$updateStmt->close();
$updateStmt = null;
}
}
@ -755,7 +749,6 @@ final class NodaWikidataFetcher {
$updateStmt->bind_param("si", $wikidata_gender, $persinst_id);
$updateStmt->execute();
$updateStmt->close();
$updateStmt = null;
}
}
@ -901,8 +894,6 @@ final class NodaWikidataFetcher {
if (!empty($languagesToFetch[$lang]) && !empty($data['sitelinks'][$lang . 'wiki'])) {
$url = $languagesToFetch[$lang];
$wikilink = $wikilinks[$lang];
if (!empty($contents[$lang])) {
@ -1060,11 +1051,9 @@ final class NodaWikidataFetcher {
LIMIT 1", "i", $onum);
if ($result->num_rows !== 0) {
$result->close();
$result = null;
return;
}
$result->close();
$result = null;
// If there is no superordinate, check if the identified superordinate
// is known in the noda DB.
@ -1078,11 +1067,9 @@ final class NodaWikidataFetcher {
if (!($superordinateData = $result->fetch_row())) {
$result->close();
$result = null;
return;
}
$result->close();
$result = null;
$topPlaceId = $superordinateData[0];
@ -1094,7 +1081,6 @@ final class NodaWikidataFetcher {
$insertStmt->bind_param("ii", $topPlaceId, $onum);
$insertStmt->execute();
$insertStmt->close();
$insertStmt = null;
}
@ -1281,8 +1267,6 @@ final class NodaWikidataFetcher {
if (!empty($languagesToFetch[$lang]) && !empty($data['sitelinks'][$lang . 'wiki'])) {
$url = $languagesToFetch[$lang];
$wikilink = $wikilinks[$lang];
if (!empty($contents[$lang])) {
@ -1364,14 +1348,13 @@ final class NodaWikidataFetcher {
FROM `tag`
WHERE `tag_id` = ?", "i", $tag_id);
if (!($cinfo = $cergebnis->fetch_assoc())) {
if (!($cinfo = $cergebnis->fetch_row())) {
$cergebnis->close();
$cergebnis = null;
return $output;
}
$cergebnis->close();
$cergebnis = null;
$tag_anmerkung = $cinfo[0];
$this->_mysqli_noda->autocommit(false);
@ -1379,12 +1362,12 @@ final class NodaWikidataFetcher {
SET `tag_anmerkung` = ?
WHERE `tag_id` = ?");
if (!empty($cinfo['tag_anmerkung']) and substr($cinfo['tag_anmerkung'], 0, 3) !== 'GND') {
if (!empty($tag_anmerkung) and substr($tag_anmerkung, 0, 3) !== 'GND') {
switch ($this->_retrievalMode) {
case "add":
$newDesc = $cinfo['tag_anmerkung'] . PHP_EOL . PHP_EOL . $datafromwiki;
$newDesc = $tag_anmerkung . PHP_EOL . PHP_EOL . $datafromwiki;
$updateTagDescStmt->bind_param("si", $newDesc, $tag_id);
$updateTagDescStmt->execute();
@ -1392,7 +1375,6 @@ final class NodaWikidataFetcher {
break;
case "keep":
$newDesc = $cinfo['tag_anmerkung'];
break;
case "replace":
@ -1410,7 +1392,7 @@ final class NodaWikidataFetcher {
echo '
<p class="alert icons iconsAlert">Es gibt schon einen Eintrag im Beschreibungsfeld</b>
<div class="wikiReplaceTTile">
<h3>Bisher vorhanden</h3><p>' . nl2br($cinfo['tag_anmerkung']) . '</p>
<h3>Bisher vorhanden</h3><p>' . nl2br($tag_anmerkung) . '</p>
</div>
<div class="wikiReplaceTTile">
<h3>Jetzt gefunden</h3><p>' . $datafromwiki . '<p>
@ -1432,7 +1414,6 @@ final class NodaWikidataFetcher {
}
$updateTagDescStmt->close();
$updateTagDescStmt = null;
$insertNodaTagStmt = $this->_mysqli_noda->do_prepare("INSERT INTO `noda_tag`
(`tag_id`, `noda_source`, `noda_nrinsource`, `noda_link`, `noda_erfasst_von`)
@ -1453,7 +1434,6 @@ final class NodaWikidataFetcher {
$updateTagEditInfoStmt->bind_param("si", $erfasst_von, $tag_id);
$updateTagEditInfoStmt->execute();
$updateTagEditInfoStmt->close();
$updateTagEditInfoStmt = null;
$this->_mysqli_noda->commit();
$this->_mysqli_noda->autocommit(true);
@ -1499,7 +1479,6 @@ final class NodaWikidataFetcher {
}
$insertNodaTagStmt->close();
$insertNodaTagStmt = null;
$this->_mysqli_noda->commit();
$this->_mysqli_noda->autocommit(true);
@ -1613,8 +1592,6 @@ final class NodaWikidataFetcher {
if (!empty($languagesToFetch[$lang]) && !empty($data['sitelinks'][$lang . 'wiki'])) {
$url = $languagesToFetch[$lang];
$wikilink = $wikilinks[$lang];
if (!empty($contents[$lang])) {