Commit 2ec27507 authored by Dries's avatar Dries
Browse files

- Patch #563106 by int: more upgrade path fixing.

parent 076d3986
......@@ -436,30 +436,29 @@ function user_update_7004(&$sandbox) {
$result = db_query_range("SELECT uid, picture FROM {users} WHERE picture <> '' AND uid > :uid ORDER BY uid", 0, $limit, array(':uid' => $sandbox['last_user_processed']));
foreach ($result as $user) {
// Don't bother adding files that don't exist.
if (!file_exists($user->picture)) {
continue;
}
if (file_exists($user->picture)) {
// Check if the file already exists.
$files = file_load_multiple(array(), array('uri' => $user->picture));
if (count($files)) {
$file = reset($files);
}
else {
// Create a file object.
$file = new stdClass();
$file->uri = $user->picture;
$file->filename = basename($file->uri);
$file->filemime = file_get_mimetype($file->uri);
$file->uid = $user->uid;
$file->status = FILE_STATUS_PERMANENT;
$file = file_save($file);
}
// Check if the file already exists.
$files = file_load_multiple(array(), array('uri' => $user->picture));
if (count($files)) {
$file = reset($files);
}
else {
// Create a file object.
$file = new stdClass();
$file->uri = $user->picture;
$file->filename = basename($file->uri);
$file->filemime = file_get_mimetype($file->uri);
$file->uid = $user->uid;
$file->status = FILE_STATUS_PERMANENT;
$file = file_save($file);
}
db_update('users')
->fields(array('picture_fid' => $file->fid))
->condition('uid', $user->uid)
->execute();
db_update('users')
->fields(array('picture_fid' => $file->fid))
->condition('uid', $user->uid)
->execute();
}
// Update our progress information for the batch update.
$sandbox['progress']++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment