X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sql%2Falter2.2.php;h=cfc914aad4293703e2b7e70907d7267e88afba1c;hb=45a035785b9a820621da56dec93078b3ccd9832e;hp=a1a4b1d5a5a5eeb66713613bad4280099ccb82b3;hpb=36ec54507b7841b2352734b81e45b95e371ecdab;p=fa-stable.git diff --git a/sql/alter2.2.php b/sql/alter2.2.php index a1a4b1d5..cfc914aa 100644 --- a/sql/alter2.2.php +++ b/sql/alter2.2.php @@ -56,14 +56,14 @@ class fa2_2 { $info = get_systype_db_info($typeno); if ($info == null || $info[3] == null) continue; $tbl = str_replace(TB_PREF, $pref, $info[0]); - $sql = "SELECT {$info[2]} as id,{$info[3]} as ref FROM $tbl"; + $sql = "SELECT DISTINCT {$info[2]} as id,{$info[3]} as ref FROM $tbl"; if ($info[1]) $sql .= " WHERE {$info[1]}=$typeno"; $result = db_query($sql); if (db_num_rows($result)) { while ($row = db_fetch($result)) { $res2 = db_query("INSERT INTO {$pref}refs VALUES(" - . $row['id'].",".$typeno.",'".addslashes($row['ref'])."')"); + . $row['id'].",".$typeno.",".db_escape($row['ref']).")"); if (!$res2) { display_error(_("Cannot copy references from $tbl") .':
'. db_error_msg($db)); @@ -103,7 +103,9 @@ class fa2_2 { if ($this->beta && !$force) $this->sql = 'alter2.2rc.sql'; - return $this->beta || !check_table($pref, 'usersonline'); + // return ok when security groups still defined (upgrade from 2.1) + // or usersonline not defined (upgrade from 2.2 beta) + return isset($security_groups) || (check_table($pref, 'usersonline')!=0); } // // Test if patch was applied before.