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']); $idata['ourlanguages']=get_instance_langs($opts['hostname']);
while (count($idata['ourlanguages'])>5) while (count($idata['ourlanguages'])>5)
array_pop($idata['ourlanguages']); array_pop($idata['ourlanguages']);
eecho(1,'«'.$opts['hostname'].'»: detected languages: '.implode(', ',$idata['ourlanguages']).N); 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 { } else {
$idata['ourlanguages']=$idata['languages']; $idata['ourlanguages']=$idata['languages'];
eecho(1,'«'.$opts['hostname'].'»: copied declared languages to detected languages.'.N); 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__); myq($link,'DELETE FROM InstOurLangs WHERE InstID='.$instid,__LINE__);
$langids=getlangsidsarr($idata['languages'],$link,$opts['hostname'],$opts['dryrun'],__LINE__); $langids=getlangsidsarr($idata['languages'],$link,$opts['hostname'],$opts['dryrun'],__LINE__);
$pos=0; $pos=0;
foreach ($idata['ourlanguages'] as $lang) { foreach ($langids as $langid) {
$pos++; $pos++;
myq($link,'INSERT INTO InstOurLangs SET InstID='.$instid.', OurLangID='.$langid.', Pos='.$pos,__LINE__); myq($link,'INSERT INTO InstOurLangs SET InstID='.$instid.', OurLangID='.$langid.', Pos='.$pos,__LINE__);
} }