<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I think I've found the answer to my own question. There are basically two loops in <font class="Apple-style-span" face="'Courier New'">process_bugs.cgi</font>, one for regular fields and one for custom fields (line numbers are from 4.2.4):<div><br></div><div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><div><font class="Apple-style-span" face="'Courier New'"> 228 my @set_fields = qw(op_sys rep_platform priority bug_severity</font></div><div><font class="Apple-style-span" face="'Courier New'"> 229 component target_milestone version</font></div><div><font class="Apple-style-span" face="'Courier New'"> 230 bug_file_loc status_whiteboard short_desc</font></div><div><font class="Apple-style-span" face="'Courier New'"> 231 deadline remaining_time estimated_time</font></div><div><font class="Apple-style-span" face="'Courier New'"> 232 work_time set_default_assignee set_default_qa_contact</font></div><div><font class="Apple-style-span" face="'Courier New'"> 233 cclist_accessible reporter_accessible </font></div><div><font class="Apple-style-span" face="'Courier New'"> 234 product confirm_product_change</font></div><div><font class="Apple-style-span" face="'Courier New'"> 235 bug_status resolution dup_id);</font></div><div><font class="Apple-style-span" face="'Courier New'"> 236 push(@set_fields, 'assigned_to') if !$cgi->param('set_default_assignee');</font></div><div><font class="Apple-style-span" face="'Courier New'"> 237 push(@set_fields, 'qa_contact') if !$cgi->param('set_default_qa_contact');</font></div><div><font class="Apple-style-span" face="'Courier New'"> ...</font></div></blockquote></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font class="Apple-style-span" face="'Courier New'"> 249 foreach my $field_name (@set_fields) {</font></div><div><font class="Apple-style-span" face="'Courier New'"> 250 if (should_set($field_name, 1)) {</font></div><div><font class="Apple-style-span" face="'Courier New'"> 251 my $param_name = $field_translation{$field_name} || $field_name;</font></div><div><font class="Apple-style-span" face="'Courier New'"> 252 $set_all_fields{$param_name} = $cgi->param($field_name);</font></div><div><font class="Apple-style-span" face="'Courier New'"> 253 }</font></div><div><font class="Apple-style-span" face="'Courier New'"> 254 }</font></div><div><font class="Apple-style-span" face="'Courier New'"> ...</font></div><div><font class="Apple-style-span" face="'Courier New'"> 338 my @custom_fields = Bugzilla->active_custom_fields;</font></div><div><font class="Apple-style-span" face="'Courier New'"> 339 foreach my $field (@custom_fields) {</font></div><div><font class="Apple-style-span" face="'Courier New'"> 340 my $fname = $field->name;</font></div><div><font class="Apple-style-span" face="'Courier New'"> 341 if (should_set($fname, 1)) {</font></div><div><font class="Apple-style-span" face="'Courier New'"> 342 $set_all_fields{$fname} = [$cgi->param($fname)];</font></div><div><font class="Apple-style-span" face="'Courier New'"> 343 }</font></div><div><font class="Apple-style-span" face="'Courier New'"> 344 }</font></div></blockquote><div><br></div><div>Note that for the first loop (the non-custom fields), <font class="Apple-style-span" face="'Courier New'">@set_fields</font> is mostly hard-coded/fixed. There's no opportunity (that I can find) to change <font class="Apple-style-span" face="'Courier New'">@set_fields</font> before the loop executes. This seems a bit weird given the availability of the <font class="Apple-style-span" face="'Courier New'">object_columns</font> and <font class="Apple-style-span" face="'Courier New'">object_update_columns</font> hooks (i.e., that neither hook affects <span class="Apple-style-span" style="font-family: 'Courier New'; ">@set_fields</span>). Does anyone know if this is intentional or if this is an oversight?</div><div></div><div><br></div><div>When I compare <font class="Apple-style-span" face="'Courier New'">$bug->UPDATE_COLUMNS</font> with <span class="Apple-style-span" style="font-family: 'Courier New'; ">@set_fields</span>, I am reminded that fields names and column names may be different:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="'Courier New'">* assigned_to</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> bug_file_loc</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> bug_severity</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> bug_status</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> cclist_accessible</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">< component_id</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">> component</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">> confirm_product_change</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> deadline</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">> dup_id</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> estimated_time</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">< everconfirmed</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> op_sys</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> priority</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">< product_id</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">> product</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">* qa_contact</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> remaining_time</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> rep_platform</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> reporter_accessible</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> resolution</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">> set_default_assignee</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">> set_default_qa_contact</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> short_desc</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> status_whiteboard</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> target_milestone</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> version</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'">> work_time</font></div></div></blockquote><div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span class="Apple-style-span" style="font-family: 'Courier New'; "><</span> = only in <font class="Apple-style-span" face="'Courier New'">$bug->UPDATE_COLUMNS</font></div></div><div><span class="Apple-style-span" style="font-family: 'Courier New'; ">></span> = only in <span class="Apple-style-span" style="font-family: 'Courier New'; ">@set_fields</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New'; ">*</span> = in both, but optional in <span class="Apple-style-span" style="font-family: 'Courier New'; ">@set_fields</span></div></blockquote><div><span class="Apple-style-span" style="font-family: 'Courier New'; "><br></span></div><div>That being said, adding <b><i>yet another</i></b> hook to allow updating extension-added fields posted to <span class="Apple-style-span" style="font-family: 'Courier New'; ">process_bugs.cgi</span> seems absurd. Does anyone have any suggestions on how to patch <span class="Apple-style-span" style="font-family: 'Courier New'; ">process_bugs.cgi</span> to modify <span class="Apple-style-span" style="font-family: 'Courier New'; ">@set_fields</span> in a sane way?</div><div><br></div><div>As always any guidance is appreciated.</div><div><br></div><div><div>
<br>
--Matt<br>
<br>
</div>
<br><div><div>On Jan 7, 2013, at 17:46, Matthew Bogosian wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; " class="">In an extension, I have created a new field using the <font class="Apple-style-span" face="'Courier New'">install_update_db</font> hook. I've managed to get the new field into the DB by running <font class="Apple-style-span" face="'Courier New'"><a href="http://checksetup.pl/">checksetup.pl</a></font>, and am able to display it for editing in <font class="Apple-style-span" face="'Courier New'">show_bug.cgi</font> using <<font class="Apple-style-span" face="'Courier New'">template/en/default/hook/bug/edit-after_custom_fields.html.tmpl</font>>.<div><br></div><div>However, whenever I try to set or change the value by submitting my changes (which get handed off to <font class="Apple-style-span" face="'Courier New'">process_bugs.cgi</font> as near as I can tell), the corresponding field is never updated. I have confirmed the new value is being passed to <font class="Apple-style-span" face="'Courier New'">process_bugs.cgi</font> as POST data when submitting the change from <font class="Apple-style-span" face="'Courier New'">show_bugs.cgi</font>.</div><div><br></div><div>I have implemented the <font class="Apple-style-span" face="'Courier New'">object_columns</font> and <font class="Apple-style-span" face="'Courier New'">object_update_columns</font> hooks <a href="http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/Hook.html#object_columns">as required</a>, but they do not seem to have any effect:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote"><div class=""><font class="Apple-style-span" face="'Courier New'">#---- Extension.pm -------------------------------------------------------</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br></font></div><div class=""><font class="Apple-style-span" face="'Courier New'">...</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br></font></div><div class=""><font class="Apple-style-span" face="'Courier New'">#========================================================================= </font></div><div class=""><font class="Apple-style-span" face="'Courier New'">sub install_update_db {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> my $dbh = Bugzilla->dbh;</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br class=""></font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> $dbh->bz_add_column('bugs', 'ip_thumb', {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> TYPE => 'INT3',</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> REFERENCES => {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> TABLE => 'attachments',</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> COLUMN => 'attach_id',</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> DELETE => 'SET NULL'</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> }</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> });</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br class=""></font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> my $field = new Bugzilla::Field({ name => 'ip_thumb' });</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br class=""></font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> if (! $field) {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> $field = Bugzilla::Field->create({</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> buglist => 1,</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> description => 'Thumbnail',</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> name => 'ip_thumb',</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> type => Bugzilla::Constants::FIELD_TYPE_FREETEXT,</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> });</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> $field->set_is_numeric(1);</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> $field->update();</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> }</font></div><div class=""><font class="Apple-style-span" face="'Courier New'">}</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br class=""></font></div><div class=""><font class="Apple-style-span" face="'Courier New'">#========================================================================= </font></div><div class=""><font class="Apple-style-span" face="'Courier New'">sub object_columns {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> my ( $self, $args ) = @_;</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> my ( $class, $columns ) = @$args{qw(class columns)};</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br class=""></font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> if ($class->isa('Bugzilla::Bug')) {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> push(@$columns, 'ip_thumb');</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> }</font></div><div class=""><font class="Apple-style-span" face="'Courier New'">}</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br class=""></font></div><div class=""><font class="Apple-style-span" face="'Courier New'">#========================================================================= </font></div><div class=""><font class="Apple-style-span" face="'Courier New'">sub object_update_columns {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> my ( $self, $args ) = @_;</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> my ( $object, $columns ) = @$args{qw(object columns)};</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br class=""></font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> if ($object->isa('Bugzilla::Bug')) {</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> push(@$columns, 'ip_thumb');</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"> }</font></div><div class=""><font class="Apple-style-span" face="'Courier New'">}</font></div><div class=""><font class="Apple-style-span" face="'Courier New'"><br></font></div><div class=""><font class="Apple-style-span" face="'Courier New'">...</font></div></blockquote><div class=""><br class=""></div><div class="">What am I doing wrong? I'm running the extension on 4.2.4. I can't find any guidance from the Example extension, the API documentation, or any other source as to why my new value is not being updated. Any help would be greatly appreciated.<br class=""><div>
<br class="">
<br class="">
--Matt<br></div></div></div></div></blockquote></div><br></div><div><br></div></body></html>