Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
8ceb72c2
Commit
8ceb72c2
authored
Feb 29, 2012
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 731559: Preload all attachment submitters when viewing a bug report
a=LpSolit
parent
40e28180
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
Attachment.pm
Bugzilla/Attachment.pm
+16
-5
Bug.pm
Bugzilla/Bug.pm
+1
-1
No files found.
Bugzilla/Attachment.pm
View file @
8ceb72c2
...
...
@@ -593,12 +593,12 @@ sub _check_is_private {
=over
=item C<get_attachments_by_bug($bug
_id
)>
=item C<get_attachments_by_bug($bug)>
Description: retrieves and returns the attachments the currently logged in
user can view for the given bug.
Params: C<$bug
_id> - integer - the ID of
the bug for which
Params: C<$bug
> - Bugzilla::Bug object -
the bug for which
to retrieve and return attachments.
Returns: a reference to an array of attachment objects.
...
...
@@ -606,14 +606,14 @@ Returns: a reference to an array of attachment objects.
=cut
sub
get_attachments_by_bug
{
my
(
$class
,
$bug
_id
,
$vars
)
=
@_
;
my
(
$class
,
$bug
,
$vars
)
=
@_
;
my
$user
=
Bugzilla
->
user
;
my
$dbh
=
Bugzilla
->
dbh
;
# By default, private attachments are not accessible, unless the user
# is in the insider group or submitted the attachment.
my
$and_restriction
=
''
;
my
@values
=
(
$bug
_
id
);
my
@values
=
(
$bug
->
id
);
unless
(
$user
->
is_insider
)
{
$and_restriction
=
'AND (isprivate = 0 OR submitter_id = ?)'
;
...
...
@@ -625,15 +625,18 @@ sub get_attachments_by_bug {
undef
,
@values
);
my
$attachments
=
Bugzilla::
Attachment
->
new_from_list
(
$attach_ids
);
$_
->
{
bug
}
=
$bug
foreach
@$attachments
;
# To avoid $attachment->flags to run SQL queries itself for each
# attachment listed here, we collect all the data at once and
# populate $attachment->{flags} ourselves.
# We also load all attachers at once for the same reason.
if
(
$vars
->
{
preload
})
{
# Preload flags.
$_
->
{
flags
}
=
[]
foreach
@$attachments
;
my
%
att
=
map
{
$_
->
id
=>
$_
}
@$attachments
;
my
$flags
=
Bugzilla::
Flag
->
match
({
bug_id
=>
$bug
_
id
,
my
$flags
=
Bugzilla::
Flag
->
match
({
bug_id
=>
$bug
->
id
,
target_type
=>
'attachment'
});
# Exclude flags for private attachments you cannot see.
...
...
@@ -641,6 +644,14 @@ sub get_attachments_by_bug {
push
(
@
{
$att
{
$_
->
attach_id
}
->
{
flags
}},
$_
)
foreach
@$flags
;
$attachments
=
[
sort
{
$a
->
id
<=>
$b
->
id
}
values
%
att
];
# Preload attachers.
my
%
user_ids
=
map
{
$_
->
{
submitter_id
}
=>
1
}
@$attachments
;
my
$users
=
Bugzilla::
User
->
new_from_list
([
keys
%
user_ids
]);
my
%
user_map
=
map
{
$_
->
id
=>
$_
}
@$users
;
foreach
my
$attachment
(
@$attachments
)
{
$attachment
->
{
attacher
}
=
$user_map
{
$attachment
->
{
submitter_id
}};
}
}
return
$attachments
;
}
...
...
Bugzilla/Bug.pm
View file @
8ceb72c2
...
...
@@ -3100,7 +3100,7 @@ sub attachments {
return
[]
if
$self
->
{
'error'
};
$self
->
{
'attachments'
}
=
Bugzilla::
Attachment
->
get_attachments_by_bug
(
$self
->
bug_id
,
{
preload
=>
1
});
Bugzilla::
Attachment
->
get_attachments_by_bug
(
$self
,
{
preload
=>
1
});
return
$self
->
{
'attachments'
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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