From ded51efe8252ac6b85456613a3ca08c2fcc901f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Tue, 2 Nov 2010 18:41:21 +0100 Subject: [PATCH] Improves a bit more the script about merge issues linked to phone. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- upgrade/1.0.1/merge_issues_phones.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/upgrade/1.0.1/merge_issues_phones.php b/upgrade/1.0.1/merge_issues_phones.php index 94651f4..af8b01b 100755 --- a/upgrade/1.0.1/merge_issues_phones.php +++ b/upgrade/1.0.1/merge_issues_phones.php @@ -28,7 +28,7 @@ while ($item = $it->next()) { printf("\r%u / %u", $i, $total); } } -printf("\r%u / %u", $i, $n); +printf("\r%u / %u", $i, $total); print "\nFormating done.\n\n"; print "Deletes duplicated phones. (2/2)\n"; @@ -41,17 +41,14 @@ $pids = XDB::rawFetchColumn("SELECT DISTINCT(pid) $total = count($pids); $done = 0; $aux = 0; +$deleted = 0; $phones = array(); $duplicates = array(); foreach ($pids as $pid) { $count = 0; - $it = XDB::iterator("SELECT search_tel AS search, display_tel AS display, comment, link_id, - tel_type AS type, link_type, tel_id AS id, pid, pub - FROM profile_phones - WHERE link_type = 'user' AND pid = {?} - ORDER BY tel_id", $pid); + Phone::iterate(array($pid), array(Phone::LINK_PROFILE), array(0)); while ($item = $it->next()) { - $phones[] = new Phone($item); + $phones[] = $item; ++$count; } for ($i = 0; $i < $count; ++$i) { @@ -65,6 +62,7 @@ foreach ($pids as $pid) { unset($phones[$key]); } if (count($phones) != $count) { + $deleted += ($count - count($phones)); Phone::deletePhones($pid, 'user'); $id = 0; foreach ($phones as $phone) { @@ -87,7 +85,9 @@ foreach ($pids as $pid) { } } printf("\r%u / %u", $done, $total); -print "\n\nThat's all folks!\n"; +print "\n$deleted phones deleted.\n\n"; + +print "That's all folks!\n"; /* vim:set et sw=4 sts=4 ts=4: */ ?> -- 2.1.4