function nodewords_update_6182 in Nodewords: D6 Meta Tags 6
Remove fields accidently stashed on users.data.
File
- ./
nodewords.install, line 1645 - Installation file for nodewords.module.
Code
function nodewords_update_6182(&$sandbox) {
$ret = array();
// The number of users to be processed per batch.
$update_size = 100;
// If this is the first time the script has ran, set up some counters.
if (!isset($sandbox['progress'])) {
$sandbox['progress'] = 0;
$sandbox['current_uid'] = 0;
// We'll -1 to disregard the uid 0...
$sandbox['max'] = db_result(db_query('SELECT MAX(uid) FROM {users}'));
}
// Get a list of all users that have not been processed already, up to the
// max number.
$users = db_query_range("SELECT\n uid, data\n FROM {users}\n WHERE uid > %d\n ORDER BY uid ASC", $sandbox['current_uid'], 0, $update_size);
// Loop over each user object.
while ($user = db_fetch_object($users)) {
$data = unserialize($user->data);
if (isset($data['nodewords'])) {
unset($data['nodewords']);
// Update the user record.
db_query("UPDATE {users}\n SET data = '%s'\n WHERE uid = %d", serialize($data), $user->uid);
}
$sandbox['current_uid'] = $user->uid;
}
$ret['#finished'] = empty($sandbox['max']) || $sandbox['current_uid'] > $sandbox['max'] ? 1 : $sandbox['current_uid'] / $sandbox['max'];
return $ret;
}