function drush_services_client_sync_users in Services Client 7
Sync all user references to insight
File
- ./
services_client.drush.inc, line 137 - Services client drush integration
Code
function drush_services_client_sync_users() {
// Disable failure notifications for drush run
global $conf;
$conf['services_client_notify'] = FALSE;
$min = drush_get_option('min');
$max = drush_get_option('max');
$hook = drush_get_option('hook', NULL);
$query = db_select('users', 'u', array(
'fetch' => PDO::FETCH_ASSOC,
))
->fields('u', array(
'uid',
));
if ($min) {
$query
->condition('uid', $min, '>=');
}
if ($max) {
$query
->condition('uid', $max, '<');
}
$result = $query
->execute();
foreach ($result as $row) {
$attempts = 0;
$sucessful = FALSE;
// Make 3 attempts to sync node
while (!$sucessful && $attempts < 3) {
unset($user->_services_client);
$attempts++;
$account = user_load($row['uid']);
$result = services_client_data_process($account, 'user_save', $hook);
if (!count($result['errors'])) {
$sucessful = TRUE;
}
elseif ($attempts < 3) {
sleep($attempts);
}
}
if (!$sucessful) {
drush_print(dt("ERROR: !uid|!name", array(
'!uid' => $account->uid,
'!name' => $account->name,
)));
}
// Prevent memory from filling
drupal_static_reset();
}
}