Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
user system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Dec 2010 at 14:42 UTC
Updated:
8 Aug 2013 at 02:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fagoLet's see what the test-bot says.
Comment #2
sunShouldn't the entire code rely on $account instead of $edit with that initial copying/overloading?
This looks like a duplicated and no longer needed operation?
Powered by Dreditor.
Comment #3
fago>Shouldn't the entire code rely on $account instead of $edit with that initial copying/overloading?
Indeed. This results in more changes though, however it are just overall $edit -> $account replacements. I've updated the patch to do so.
Updated patch attached.
>This looks like a duplicated and no longer needed operation?
It was necessary, as $edit was changed above and might be changed by drupal_write_record(). Anyway, for the updated patch I've improved that to just case $account to $edit, as well on insert everything we save has to be new.
Regarding, drupal_write_record(). I noticed:
This could and probably should be fixed by making 'uid' a serial field. I've not touched that for now, we can still do so in a follow-up.
Comment #4
sunThis looks really really good.
Somehow, this variable assignment looks wrong to me. ->fid is empty, if there is no picture yet, so $delete_previous_picture will be TRUE, when ->fid is empty, but just because of the final negation, we're entering the condition. However, the variable contains the wrong/negated value.
Technically, that's a separate issue though. However, my next best thought was that we can entirely remove that $delete_previous_picture negotiation, because we have $account->original->picture->fid now.
We can still ensure this via $account->original->uid
It looks like we always updated user roles -- let's not do unnecessary behavior changes.
Same here -- if the account's status is 0, then we always need to ensure that the user's session is destroyed.
Why don't we use the simple array cast in the update case, too?
Powered by Dreditor.
Comment #5
fago>It looks like we always updated user roles -- let's not do unnecessary behavior changes.
No, $edit previously only contained the changes (at least it was supposed to be used like that I guess). So my code doesn't do improvements/changes, it's keeping the way it was.
>Same here -- if the account's status is 0, then we always need to ensure that the user's session is destroyed.
The same again ;)
>Why don't we use the simple array cast in the update case, too?
As it's not equivalent. $edit should only contain the stuff people passed as $edit + what changed. I'd be fine with $edit containing everything, but that would be small API change...
>We can still ensure this via $account->original->uid
Fixed that.
I've also fixed the picture-logic to process uploads when the picture changed. Indeed, the previous check was weird and I think it never deleted picture files. Just checking $account->original->picture->fid won't be enough though, as again - $edit is just considered to contain the changes only. As, of course it should only delete the old file, if a new one was uploaded. Aanyway, I just moved the hunk removing deprecated pictures up in the if clause, so we don't need that variable at all.
Comment #6
sunAlright, thanks for clarifying. user_save() is sufficiently covered by tests, so this patch looks ready to fly to me.
Also, trying to set a better title.
Comment #7
yched commentedwow, subscribe :-)
Comment #8
yched commentedMinor nit: there is one leftover instance of the $delete_previous_picture variable, now useless.
Comment #9
fagothanks, removed that line.
When looking at the picture upload code again, I think this needs a clean-up. E.g. the line
is useless, as both objects are the same anyway. Thus, it is going to store a reference on a temporary file, if moving the file fails. Anyway, I think fixing that logic is out of scope for this issue, so let's do it in a follow-up.
Comment #10
sunEven better, thanks!
Comment #11
fago#9: drupal_user_save.patch queued for re-testing.
Comment #12
pillarsdotnet commentedRe-rolled, with improvements. (FINALLY found the original issue where I stole this patch from...)
Comment #14
pillarsdotnet commented#9: drupal_user_save.patch queued for re-testing.
Comment #15
pillarsdotnet commented#12: 999004-user.module.patch queued for re-testing.
Comment #17
bcn commentedExtra space...
Also, it seems that this new bit is causing the test failure.
Powered by Dreditor.
Comment #18
sunRe-uploading @fago's latest patch from #9. No clue why @pillarsdotnet tried to change it. Back to RTBC.
Comment #19
pillarsdotnet commentedWith the patch in #9, if I upload a user image, it shows on my screen as a broken link. With the patch I posted (sorry about the trailing space), if I upload a user image, it shows on my profile and on my posts.
So I should open a separate issue after this patch makes it in?
Comment #20
bfroehle commented@pillarsdotnet: Yes, create a separate issue. You can do so right away -- there is no need to wait for this issue to be resolved. Unless, of course, this user image problem was created by the patch in #9 at which point we would need to fix the patch.
Comment #21
sun#18: drupal_user_save_2.patch queued for re-testing.
Comment #22
fagoComment #23
fago#18: drupal_user_save_2.patch queued for re-testing.
Comment #24
fagoLooks like I managed to confuse the test bot.
Re-uploading the latest patch from #9.
Comment #25
sun#24: drupal_user_save_2.patch queued for re-testing.
Comment #26
rszrama commentedGiving this patch another +1. Works for me and fixes a problem in Rules that affects Drupal Commerce. ; )
Comment #27
fagoLet's shortly explain what's the problem over there: As of now user_save() behaves different than any other entity save function in terms of that its changes won't appear in the originally passed object, but a new, different object incorporating the changes is returned.
This is the cause for entity_save() in contrib to require the entity to be passed by reference as of now, see #1002700: entity_save() should not accept object arguments by reference.. In case of Rules this reference probably is lost somewhere, so the updates to the user object won't appear later on, i.e. $user->uid is not set after saving a new user.
As a side-effect from cleaning up user_save() as outlined in the first post the patch from #9 also fixes that discrepancy.
Let's stop having user_save() violating the API by passing fake-entities as entities (as seen in #985642-5: Remove file_attach_load() from file_field_update()) and get this in.
Comment #28
alpritt commentedJust a note so I can keep an eye on this issue because it is going to break the patch for #935592: User picture is deleted after calls to user_save(). It makes sense to get this one in first as it looks like it may fix that other issue too.
Comment #29
omnyx commenteddoes anyone know what the status on this is?
cheers,
Comment #30
bdragon commentedSubscribing.
Comment #31
catchComment #32
DocuAnt commentedSubscribing.
Comment #33
pillarsdotnet commentedGratuitous re-roll for both d8 and d7. No changes other than this one is made with "git format-patch" and without the "-p0" option.
Comment #34
DocuAnt commentedIs there a way to push this issue to ensure that this will be fixed in the next Drupal 7 Version?
(losing user content is a very serious and annoying problem causing a lot of frustrations...)
Comment #35
sunIs there a RTBC RTBC...? I've no idea why this patch keeps on languishing around in the queue. It
Comment #36
DocuAnt commentedYes, this is a really badly required patch because there are probably some more issues connected to the disappearing user pictures:
#935592: User picture is deleted after calls to user_save()
#1063098: User picture and other image fields dissapear when I save
#1126000: [meta] hook_field_*() called on fields not set in the $entity object (partial updates)
Comment #37
catchSince this blocks the other issue with user pictures going missing, I'm bumping to critical. That bug has current patches, we can add tests over there.
Comment #39
fagoThis major/critical issue is RTBC for more than 4 months now and has not yet got a single response from a core committer. That's frustrating.
Comment #40
catchLike so many other issues in the queue sadly.
Comment #41
DocuAnt commentedLike in the tale of Sisyphus ...
user changing user data ... user picture deleted ... restoring user picture ...
admin changing user role ... user picture deleted ... restoring user picture ...
Please destroy the boulder and make me running up the hill of drupal. :-)
Comment #42
tstoecklerJust for the heck of it.
+1 RTBC.
Comment #43
andypostSuppose this tag still valid
Comment #44
dries commented#33: user_save-cleanup-999004-33-d-8.patch queued for re-testing.
Comment #45
dries commentedI reviewed this patch and it is ready to be committed to D8 from looking at the code. I tried to apply it to my local 8.x branch it failed so I just asked for a re-test from the testbot. This patch can go in quickly now but might need a reroll. Let's see what the testbot has to say.
Comment #47
dries commentedWill need a quick reroll for D8.
Comment #48
catchPatch was broken by #61856: In user.module, trim() user-submitted email address before validation. I tried reverting that patch and applying this one, but it still didn't apply, that's all the time I have for this issue today, hopefully someone else has time to re-roll. The number of RTBC critical issues that have been stalled by minor commits on other issues in the past couple of months is unacceptable.
Comment #49
pillarsdotnet commentedRe-roll of #33 for current 8.x checkout.
Comment #50
catchThanks pillarsdotnet!
Comment #51
lyricnz commentedAppears to break user creation. Note 0 passes in previous green.
Comment #52
catch#49: user_save-cleanup-999004-49.patch queued for re-testing.
Comment #53
dries commentedSmall code style glitch in the patch but I fixed that upon commit. Committed to 8.x.
I committed it with the wrong commit message though; used the one from #935592: User picture is deleted after calls to user_save(). I apologize for that.
Comment #54
lyricnz commentedI believe this commit has broken user-creation in D8 - the error in #51 is now in core.
Comment #55
bfroehle commentedComment #56
catchLet's roll back to #49 (note that Dries made a minor code style change in #53, but it should be fine to revert the commit in git) and work from there.
Comment #58
catchYeah now the patch fails...
Comment #59
dries commentedRolled back the patch, and updating the status.
Comment #60
bfroehle commented#49: user_save-cleanup-999004-49.patch queued for re-testing.
Comment #61
pillarsdotnet commentedEDIT: Please ignore and see #62 instead, sigh.
Comment #62
pillarsdotnet commentedRe-rolled to fix code style glitch, but also changing to CNW.
I did have to change some of the patch to cope with changes from #61856.
Interdiff from #33 also attached.
Comment #63
sun@pillarsdotnet: Sorry for playing devil's advocate, but you didn't state that you had larger issues re-rolling the patch. If that would have been clear since #33, someone would surely have taken the time to compare and review the re-rolled patch against the original in detail. I don't think that @fago, @catch, or me took the time to review the re-rolled patch in detail because of that missing communication.
I considered twice whether I should re-review the re-rolled patch. In turn, now it's @catch and me who're to blame for having HEAD broken for quite some time - unfortunately, in a situation that's sufficiently heated/hopeless/problematic anyway already.
Everyone, apologies for causing this trouble.
Comment #64
pillarsdotnet commentedSorry, too. I did try to run testing locally before updating but it was taking too long, even with mysql running from a ramdisk.
I didn't imagine that Dries would commit without waiting for testbot to finish. but perhaps he was feeling pressured by the multitude of complaints that the whole update process is too slow.
Looking at the interdiff I can't see what is causing the breakage, but there it is.
Comment #65
pillarsdotnet commentedComment #66
marcingy commentedThe issue this line has been introduced via another patch
Reroll of patch removing this line - all user tests have run successfully locally. Otherwise this is the same as #33.
Comment #67
pillarsdotnet commentedInterdiff between #62 and #66 shows a lot more changes than just one line.
Comment #68
marcingy commentedYour interdiff show lines related to translations which are not part of this patch. As stated this is based on #33 and removes the issue with an extra drupal_record_write for user that has been introduced.
Comment #69
marcingy commentedSo this passes - I know the norm isn't to rtbc your own patches but we live in interesting times.....and we want to get d7 ship shape. Hopefully someone will second this.
Comment #70
fagook, I've manually gone through all the changes and I can second the re-roll of #66 is fine, thus again RTBC.
I think it happened in #49 though, which the test-bot marked green without actually testing it. Bad luck. :(
Comment #71
sunConfirming. Also reviewed #66 and it's identical to the original in #24.
Comment #72
sunRemoving bogus tag.
Comment #73
dries commentedLet's try this again. Committed to 8.x. Moving to 7.x.
Comment #74
webchickCommitted to 7.x, too.
I think I was hesitant around this one back before release because it was re-working internals and I was concerned about API breakage. However, in reviewing it more closely, it does indeed just make this function conform to the standard set out by the remainder of the various other entity functions.
Hopefully this is early enough that it won't screw up any module devs. I guess we have a week or so to test it before 7.1 comes out.
Comment #75
rszrama commentedEpic win. Thanks everyone. : )
Comment #77
pillarsdotnet commentedMarked as a duplicate: #935592-41: User picture is deleted after calls to user_save()
Comment #78
Anonymous (not verified) commentedthis broke cleaning up user picture files - #1378092: User pictures are not removed properly
dear deity we need tests...
Comment #79
TelFiRE commentedWas this ever committed to core? Has it somehow been re-triggered? I never had these versions of Drupal, started on 7.22, yet I am experiencing this issue.
I have three rules, meant to update roles based on the status of a field, when the user profile is saved. They work but also delete the user picture.