Mercurial > hg > rc2
comparison bin/indexcontacts.sh @ 8:bf99236cc5cd default tip
try to recover from upgrade fail
author | Charlie Root |
---|---|
date | Sat, 29 Dec 2018 07:07:34 -0500 |
parents | 4681f974d28b |
children |
comparison
equal
deleted
inserted
replaced
7:65fd7d441cf1 | 8:bf99236cc5cd |
---|---|
22 define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' ); | 22 define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' ); |
23 | 23 |
24 require_once INSTALL_PATH.'program/include/clisetup.php'; | 24 require_once INSTALL_PATH.'program/include/clisetup.php'; |
25 ini_set('memory_limit', -1); | 25 ini_set('memory_limit', -1); |
26 | 26 |
27 // connect to DB | 27 rcmail_utils::indexcontacts(); |
28 $RCMAIL = rcube::get_instance(); | |
29 | |
30 $db = $RCMAIL->get_dbh(); | |
31 $db->db_connect('w'); | |
32 | |
33 if (!$db->is_connected() || $db->is_error()) { | |
34 rcube::raise_error("No DB connection", false, true); | |
35 } | |
36 | |
37 // iterate over all users | |
38 $sql_result = $db->query("SELECT `user_id` FROM " . $db->table_name('users', true) . " ORDER BY `user_id`"); | |
39 while ($sql_result && ($sql_arr = $db->fetch_assoc($sql_result))) { | |
40 echo "Indexing contacts for user " . $sql_arr['user_id'] . "..."; | |
41 | |
42 $contacts = new rcube_contacts($db, $sql_arr['user_id']); | |
43 $contacts->set_pagesize(9999); | |
44 | |
45 $result = $contacts->list_records(); | |
46 while ($result->count && ($row = $result->next())) { | |
47 unset($row['words']); | |
48 $contacts->update($row['ID'], $row); | |
49 } | |
50 | |
51 echo "done.\n"; | |
52 } | |
53 | 28 |
54 ?> | 29 ?> |