From: Will Budic Date: Sun, 23 Feb 2020 09:24:03 +0000 (+1100) Subject: Auto populate check on old upgrade, for Categories. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=2eb2d91d2bd58f5af4d91a51a3e6838eba777176;p=LifeLog.git Auto populate check on old upgrade, for Categories. --- diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 04cfe22..4051133 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -409,12 +409,15 @@ $err .= "Invalid, spec'ed {uid}|{variable}`{description}-> $line\n"; }elsif($ttype==1){ my @pair = $tick[0] =~ m[(\S+)\s*\|\s*(\S+\s*\S*)]g; if ( scalar(@pair)==2 ) { - my $st = $db->prepare("SELECT ID FROM CAT WHERE NAME LIKE '$pair[1]';"); - $st->execute(); - $inData = 1; - if(!$st->fetchrow_array()) { - $insCat->execute($pair[0],$pair[1],$tick[1]); + # In older DB versions the Category name could be different, user modified. + # The unique id and name interwined, changed. Hence we check on name first. + # Then check if the ID is available. If not just skip, the import. Reseting can fix that latter. + if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE NAME LIKE '$pair[1]';")->fetchrow_array()) { + if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE ID = $pair[0];")->fetchrow_array()){ + $insCat->execute($pair[0],$pair[1],$tick[1]); + } } + $inData = 1; } else { $err .= "Invalid, spec'ed {uid}|{category}`{description}-> $line\n";