Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
user.module
Priority:
Critical
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
19 Mar 2010 at 19:29 UTC
Updated:
3 Jan 2014 at 01:08 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rfayWouldn't a query like
db_result('select count(*) from {users} where...'));be better, and then actually return the result? Isn't the hook supposed to return the actual number of references?I know that in core, it's always going to be one, given current assumptions. But there's no reason this shouldn't be a more "sane" query.
150 critical left. Go review some!
Comment #2
andypostpatch to return actual count
Comment #3
dries commentedThis looks correct to me. Marking RTBC so I can commit it later.
Comment #4
dries commentedCommitted to CVS HEAD.
Comment #5
catchThis patch was an almost direct revert of #196862: COUNT(*) is an expensive query in InnoDB., please re-revert.
Comment #6
rfaySorry, @andypost :-(
@catch, shouldn't we change the signature of hook_file_references to return a bool, then? We aren't going to want to ever return a count are we? In PHP, this is really just a change to the documentation, I think, but we should do that. The hook should return TRUE if there are existing files.
Comment #7
eojthebraveerr. cross posted with above comment ...
What is the appropriate way to do this with respect to InnoDB? Store a variable with the count? Select all rows and count them in PHP?
hook_file_references() says that you should return a count of the total number of uses of the file.
As @rfay points out in #1, given current assumptions in core just returning 1 or 0 will work but does that potentially break things for contrib?
Comment #8
catchThat makes sense to me. I can't see a use-case for returning a count here.
Comment #9
andypost@catch The use case is when some contrib module is sharing one image per set of users. Suppose it's possible to have one avatar per group of users.
Comment #10
andypostSuppose in this case 1 is enough to indicate that file still used for some picture.
EDIT: There's still TODO in http://api.drupal.org/api/function/template_preprocess_user_picture/7
Comment #11
catch// If file still user then 1 is enough to indicate.This should be
// If file is still used then 1 is enough to indicate this.Otherwise RTBC.
Comment #12
andypostPatch with proposed comment
Comment #13
catchThis looks good. We should open a separate issue to change hook_file_references() documentation. Although there's also #353458: hook_file_references() was not designed for a highly flexible field storage.
Comment #14
rfayI think we'll be accidentally rewriting this function forever if we don't change the signature of hook_file_references(). @catch, you're the keeper of this. Should hook_file_references() return a bool?
Comment #15
catchI think it should, but I have zero knowledge of what that field storage issue is proposing and how that'd interact with the changes here.
Comment #16
dries commentedSorry about that! I committed the updated patch to HEAD. Thanks.
Comment #17
andypostStill nothing was commited?! http://drupal.org/project/cvs/3060
Comment #18
andypostRe-roll last patch, back to RTBC because it was not commited
Comment #19
andyposthttp://drupal.org/cvs?commit=346060