Actualiser api.php
This commit is contained in:
@@ -171,7 +171,8 @@ function fetchPhysicalFromUpcitemdb($ean) {
|
|||||||
'length' => ''
|
'length' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
unction fetchPhysicalFromUpcmdb($ean, $pdo) {
|
|
||||||
|
function fetchPhysicalFromUpcmdb($ean, $pdo) {
|
||||||
$empty = ['title'=>'','publisher'=>'','format'=>'','length'=>'','number_of_discs'=>1,'aspect_ratio'=>'','year'=>''];
|
$empty = ['title'=>'','publisher'=>'','format'=>'','length'=>'','number_of_discs'=>1,'aspect_ratio'=>'','year'=>''];
|
||||||
$apiKey = getUpcmdbApiKey($pdo);
|
$apiKey = getUpcmdbApiKey($pdo);
|
||||||
if (!$apiKey) return $empty;
|
if (!$apiKey) return $empty;
|
||||||
@@ -199,7 +200,6 @@ unction fetchPhysicalFromUpcmdb($ean, $pdo) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function fetchPhysicalByEan($ean, $pdo = null) {
|
function fetchPhysicalByEan($ean, $pdo = null) {
|
||||||
$res = fetchPhysicalFromUpcitemdb($ean);
|
$res = fetchPhysicalFromUpcitemdb($ean);
|
||||||
if (!empty($res['title'])) return $res;
|
if (!empty($res['title'])) return $res;
|
||||||
@@ -403,7 +403,8 @@ case 'save_config':
|
|||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
";
|
";
|
||||||
$result = $pdo->query($sql)->fetchAll();
|
$result = $pdo->query($sql)->fetchAll();
|
||||||
foreach ($result as $row) {
|
// IMPORTANT : Utilisation du pointeur `&` pour que la modification soit effective dans $result
|
||||||
|
foreach ($result as &$row) {
|
||||||
if ($row['rating'] !== null) {
|
if ($row['rating'] !== null) {
|
||||||
$ratingVal = (float)$row['rating'];
|
$ratingVal = (float)$row['rating'];
|
||||||
$row['rating'] = ($ratingVal == floor($ratingVal)) ? (int)$ratingVal : $ratingVal;
|
$row['rating'] = ($ratingVal == floor($ratingVal)) ? (int)$ratingVal : $ratingVal;
|
||||||
@@ -554,4 +555,3 @@ case 'import_batch':
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user