Bug 427914 - XMLRPC function addAttachment
XMLRPC function addAttachment
Status: CLOSED NEXTRELEASE
Product: Bugzilla
Classification: Community
Component: WebService (Show other bugs)
3.2
All Linux
high Severity medium (vote)
: ---
: ---
Assigned To: David Lawrence
:
Depends On:
Blocks: 406131 427053
  Show dependency treegraph
 
Reported: 2008-01-07 21:03 EST by Noura El hawary
Modified: 2013-06-24 00:18 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-09-22 10:48:12 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Patch to add bugzilla.addAttachment functionality to bz 3.2 (v1) (10.90 KB, patch)
2008-09-19 15:13 EDT, David Lawrence
nelhawar: review+
Details | Diff

  None (edit)
Description Noura El hawary 2008-01-07 21:03:55 EST
write xmlrpc function addAttachment that is to be contributed to the upstream.
Please refer to the following url for details on Bugzilla::RPC 2.18 functions mapped to upstream Bugzilla::WebService and for 2.18 xmlrpc functions sorted by percentage of calls: https://engineering.redhat.com/trac/bugzilla-3.0-rh/wiki/XmlrpcCrossComparison#a2.18xmlrpcfunctionssortedbypercentageofcalls
Comment 1 David Lawrence 2008-09-19 15:13:30 EDT
Created attachment 317227 [details]
Patch to add bugzilla.addAttachment functionality to bz 3.2 (v1)

Patch attached that ports bugzilla.addAttachment() from 2.18 to 3.2.

Please review
Thanks
Dave
Comment 2 Noura El hawary 2008-09-21 11:45:30 EDT
Comment on attachment 317227 [details]
Patch to add bugzilla.addAttachment functionality to bz 3.2 (v1)

Hi Dave,

The function looks good to me and works nicely only 2 points listed below:

>Index: extensions/compat_xmlrpc/code/webservice.pl
>===================================================================

>+sub addAttachment {
>+    my ($self, $bug_id, $data, $username, $password) = @_;
>+    my $dbh  = Bugzilla->dbh;
>+    my $user = Bugzilla->user;
>+
>+    # Try to login if $username and $password provided.
>+    xmlrpc_client_login($username, $password, LOGIN_REQUIRED);
>+    

my $user = Bugzilla->user;  ==> this should be here or otherwise if the user uses the function parameters to login the function will fail.


>+
>+    # Set the content type to text/plain if the attachment is a patch.
>+    my $contenttype = $ispatch ? "text/plain" : $data->{'contenttype'};
>+    $contenttype || ThrowUserError("missing_content_type");
>+


also shall we throw an error in the case of invalid contenttype just as how the webui does as the following from Bugzilla/Attachment.pm:

    if ( $contenttype !~
           /^(application|audio|image|message|model|multipart|text|video)\/.+$/ ) {
            ThrowUserError("invalid_content_type",
                           { contenttype => $contenttype });
    }


Thanks,
Noura
Comment 3 David Lawrence 2008-09-22 10:48:12 EDT
Thanks Noura. Made the changes you suggested and checked in.

Dave

Note You need to log in before you can comment on or make changes to this bug.