Fixed writing langs ids to InstOurLangs; made detected languages fall back to declared languages when they can't be detected

This commit is contained in:
pezcurrel 2023-01-01 19:50:57 +01:00
parent fa97078fe4
commit 6f296a1d27

View file

@ -656,7 +656,12 @@ if ($instanswered && isset($idata['languages']) && is_array($idata['languages'])
$idata['ourlanguages']=get_instance_langs($opts['hostname']);
while (count($idata['ourlanguages'])>5)
array_pop($idata['ourlanguages']);
if (count($idata['ourlanguages'])>0) {
eecho(1,'«'.$opts['hostname'].'»: detected languages: '.implode(', ',$idata['ourlanguages']).N);
} else {
$idata['ourlanguages']=$idata['languages'];
eecho(1,'«'.$opts['hostname'].'»: detected languages: NONE; copied declared languages to detected languages.'.N);
}
} else {
$idata['ourlanguages']=$idata['languages'];
eecho(1,'«'.$opts['hostname'].'»: copied declared languages to detected languages.'.N);
@ -665,7 +670,7 @@ if ($instanswered && isset($idata['languages']) && is_array($idata['languages'])
myq($link,'DELETE FROM InstOurLangs WHERE InstID='.$instid,__LINE__);
$langids=getlangsidsarr($idata['languages'],$link,$opts['hostname'],$opts['dryrun'],__LINE__);
$pos=0;
foreach ($idata['ourlanguages'] as $lang) {
foreach ($langids as $langid) {
$pos++;
myq($link,'INSERT INTO InstOurLangs SET InstID='.$instid.', OurLangID='.$langid.', Pos='.$pos,__LINE__);
}