you are going to have to give us the full error. The code you posted does not try to get an array key of count
Jul 2, 2023
11
Level 1
Undefined array key "count"
I'm using a package in a Jobs, but it keeps failing:
ErrorException: Undefined array key "count" in /var/www/vhosts/***.it/httpdocs/vendor/askancy/howlongtobeat/src/HowLongToBeat.php:74
Basically the verification error when I search for an item that does not exist, but why does it fail all the jobs instead of just skipping it? The package is: https://github.com/Askancy/howlongtobeat
In my jobs I have tried to insert several controls as well, but it keeps failing, giving me the error array key count...
Games::chunk($chunkSize, function ($games) {
foreach ($games as $game) {
$hl = HowLong2Beat::where('id_game', $game->id)->firstOrFail();
if ($hl) {
/* If the game exists let's go by ID */
$hl2b = new HowLongToBeat();
$results = $hl2b->get($hl->id_hltb);
$hl->id_game = $game->id;
$hl->id_hltb = $results['ID'];
$hl->mainstory = Str::replace(' Hours', '', $results['Summary']['Main Story']);
$hl->mainextra = Str::replace(' Hours', '', $results['Summary']['Main + Extra']);
$hl->complete = Str::replace(' Hours', '', $results['Summary']['Completionist']);
$hl->save();
} else {
/*
If it doesn't exist we query HowLongToBeat.
We check if the searched game exists in their database
*/
$hl2b = new HowLongToBeat();
$result = $hl2b->search(htmlspecialchars_decode($game->nome));
if (count($result['Results']) > '1' ) {
/* Se il risultato esiste */
$hl = new HowLong2Beat();
$results = $result['Results'][0];
$hl->id_game = $game->id;
$hl->id_hltb = $results['ID'];
$hl->mainstory = Str::replace(' Hours', '', $results['Summary']['Main Story']);
$hl->mainextra = Str::replace(' Hours', '', $results['Summary']['Main + Extra']);
$hl->complete = Str::replace(' Hours', '', $results['Summary']['Completionist']);
$hl->save();
logger('Error-hl2b: '.$game->id);
} else {
}
}
}
});
Do you have any advice for solving this problem?
Please or to participate in this conversation.