'PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array
Since I've updated to PHP 8.x the toolptips aren't working anymore:
'PHP message: PHP Warning: Undefined array key "game_id" in /var/www/vhosts/my-domain.net/httpdocs/_eqdkp/infotooltip/infotooltip_feed.php on line 86PHP message: PHP Warning: Undefined array key "data" in /var/www/vhosts/my-domain.net/httpdocs/_eqdkp/infotooltip/infotooltip_feed.php on line 86PHP message: PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in /var/www/vhosts/my-domain.net/httpdocs/_eqdkp/infotooltip/infotooltip.class.php:362\nStack trace:\n#0 /var/www/vhosts/my-domain.net/httpdocs/_eqdkp/infotooltip/infotooltip.class.php(362): implode()\n#1 /var/www/vhosts/my-domain.net/httpdocs/_eqdkp/infotooltip/infotooltip_feed.php(86): infotooltip->getitem()\n#2 {main}\n thrown in /var/www/vhosts/my-domain.net/httpdocs/_eqdkp/infotooltip/infotooltip.class.php on line 362', referer: https://www.my-domain.net/
infotooltip_feed.php:
$item = $itt->getitem($data['name'], $data['lang'], $data['game_id'], $data['update'], $data['data']);
infotooltip.class.php:
public function getitem($item_name, $lang=false, $game_id=false, $forceupdate=false, $data=array()) {
$item_name = htmlspecialchars_decode($item_name, ENT_QUOTES);
$game = $this->config['game'];
$this->pdl->log('infotooltip', 'getitem called: item_name: '.$item_name.', lang: '.$lang.', game_id: '.$game_id.', forceupdate: '.(($forceupdate) ? 'true' : 'false') .', data: '.implode($data, ', '));
$lang = (!$lang || $lang == '') ? $this->config['game_language'] : $lang;
$this->init_cache();
$ext = '';
if(count($data) > 0) {
$ext = '_'.base64_encode(serialize($data));
}
if(!$forceupdate) {
$cache_name = $this->config['game'].'_'.$lang.'_'.($game_id ? $game_id : $item_name).$ext;
$this->pdl->log('infotooltip', 'Search in cache: '.$cache_name);
$cache_name = md5($cache_name).'.itt';
if(in_array($cache_name, $this->cached)) {
$item = unserialize(file_get_contents($this->pfh->FilePath($cache_name, 'itt_cache')), array('allowed_classes' => false));
if(isset($item['baditem'])){
$this->pdl->log('infotooltip', 'Item found, but item is baditem. forceupdate set to true.');
$forceupdate = true;
} else {
$this->pdl->log('infotooltip', 'Item found.');
return $this->item_return($item);
}
} else { //check for language
$this->pdl->log('infotooltip', 'Item not found. Check if language '.$lang.' is available.');
$this->load_parser(false, true);
$new_lang_set = false;
$before_lang = $lang;
foreach($this->config['prio'] as $parsing) {
if(!isset($this->parser_info[$game][$parsing]->av_langs[$before_lang])) {
$mid_lang = $this->config['game_language'];
$new_lang_set = true;
if(!isset($this->parser_info[$game][$parsing]->av_langs[$mid_lang])) {
$mid_lang = key($this->parser_info[$game][$parsing]->av_langs);
}
} else {
$new_lang_set = false;
break;
}
}
if($new_lang_set) {
$this->pdl->log('infotooltip', 'Language was not available. Changed language to '.$mid_lang.'. Search again.');
$lang = $mid_lang;
return $this->getitem($item_name, $lang, $game_id, $forceupdate, $data);
}
$this->pdl->log('infotooltip', 'Language is available.');
}
}
if($forceupdate) {
$this->pdl->log('infotooltip', 'Force item-update.');
$this->delete_item($item_name, $lang, $game_id, $ext);
}
$item = $this->update($item_name, $lang, $game_id, $data);
return $this->item_return($item);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
