[Rt-devel] PATCH: RT 3.6.0 REST interface - hard-coded value prevents extension of REST API

Philip Kime pkime at Shopzilla.com
Tue Jun 27 19:59:50 EDT 2006


When extending the REST API for the AT extension, I came across this
problem. I hope I've diagnosed it correctly. This patch certainly fixes
the problem and doesn't seem to cause any other problems. I've been
using the patch for several months now.

To reproduce
-------------------
/usr/local/rt/bin/rt create -t asset set Name=test9 Status=qa
Type=Servers
# Unknown object type: Servers

Comments
----------------
This is a problem in $rtroot/share/html/REST/1.0/dhandler at line 144

$k->{type} never exists as this would be a CLI Field=Value setting and
there is no  "Type" field for any RT types. This would normally go
unnoticed. However, in AT,  "Type" is an Asset subtype and hard-wired as
a basic field type for all Assets.  Looking for a "Type" form field to
set the RT object type finds this and sets it to something that is an
unknown RT object type (like "Servers" or "Storage" for example).

Patch below.

*** dhandler-3.6.orig	2006-06-07 16:15:48.783029976 -0700
--- /usr/local/rt3.6rc3/share/html/REST/1.0/dhandler	2006-06-07
16:18:45.180213528 -0700
***************
*** 141,147 ****
              my ($type, $id);
  
              # Look for matching types in the ID, form, and URL.
!             $type = exists $k->{type} ? $k->{type} : $utype;
              $type =~ s|^(?:$utype)?|$utype/| if $utype;
              $type =~ s|/$||;
  
--- 141,148 ----
              my ($type, $id);
  
              # Look for matching types in the ID, form, and URL.
!             $type = $utype || $k->{id};
!             $type =~ s|^([^/]+)/\d+$|$1| if !$utype;
              $type =~ s|^(?:$utype)?|$utype/| if $utype;
              $type =~ s|/$||;
  


More information about the Rt-devel mailing list