Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
ad9c37ff
Commit
ad9c37ff
authored
Mar 25, 2010
by
Dries Buytaert
Browse files
- Patch
#747464
by andypost: fixed wrong usage of hook_file_references().
parent
cca8e7e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/system/system.api.php
View file @
ad9c37ff
...
...
@@ -1734,10 +1734,10 @@ function hook_file_move($file, $source) {
*/
function
hook_file_references
(
$file
)
{
// If user.module is still using a file, do not let other modules delete it.
$
count
=
(
int
)
db_query
(
'SELECT
COUNT(picture)
FROM {user
s
} WHERE pict
u
re = :fid'
,
array
(
':fid'
=>
$file
->
fid
))
->
fetchField
();
if
(
$
count
)
{
$
file_used
=
(
bool
)
db_query
_range
(
'SELECT
1
FROM {user} WHERE pict
i
re = :fid'
,
0
,
1
,
array
(
':fid'
=>
$file
->
fid
))
->
fetchField
();
if
(
$
file_used
)
{
// Return the name of the module and how many references it has to the file.
return
array
(
'user'
=>
$count
);
return
array
(
'user'
=>
1
);
}
}
...
...
modules/user/user.module
View file @
ad9c37ff
...
...
@@ -773,10 +773,11 @@ function user_file_download($uri) {
*/
function
user_file_references
(
$file
)
{
// Determine if the file is used by this module.
$
count
=
(
int
)
db_query
(
'SELECT
COUNT(1)
FROM {users} WHERE picture = :fid'
,
array
(
':fid'
=>
$file
->
fid
))
->
fetchField
();
if
(
$
count
)
{
$
file_used
=
(
bool
)
db_query
_range
(
'SELECT
1
FROM {users} WHERE picture = :fid'
,
0
,
1
,
array
(
':fid'
=>
$file
->
fid
))
->
fetchField
();
if
(
$
file_used
)
{
// Return the name of the module and how many references it has to the file.
return
array
(
'user'
=>
$count
);
// If file is still used then 1 is enough to indicate this.
return
array
(
'user'
=>
1
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment