[otrs-cvs] ITSMConfigItem/Kernel/System ITSMConfigItem.pm, 1.44, 1.45

CVS commits notifications of OTRS.org cvs-log at otrs.org
Fri May 2 19:39:36 GMT 2008


Comments:
Update of /home/cvs/ITSMConfigItem/Kernel/System
In directory lancelot:/tmp/cvs-serv6822/Kernel/System

Modified Files:
	ITSMConfigItem.pm 
Log Message:
Fixed bug# 2841 - NameSearch fails in the VersionSearch() function.

Author: mh

Index: ITSMConfigItem.pm
===================================================================
RCS file: /home/cvs/ITSMConfigItem/Kernel/System/ITSMConfigItem.pm,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** ITSMConfigItem.pm	2 May 2008 12:58:07 -0000	1.44
--- ITSMConfigItem.pm	2 May 2008 19:39:31 -0000	1.45
***************
*** 104,107 ****
--- 104,149 ----
      my ( $Self, %Param ) = @_;
  
+     # WORKAROUND: set empty last_version_id in configitem table
+     {
+ 
+         # get config items with empty last_version_id
+         $Self->{DBObject}->Prepare(
+             SQL => "SELECT id FROM configitem WHERE "
+                 . "last_version_id = 0 OR last_version_id IS NULL",
+         );
+ 
+         # fetch the result
+         my @ConfigItemIDs;
+         while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
+             push @ConfigItemIDs, $Row[0];
+         }
+ 
+         CONFIGITEMID:
+         for my $ConfigItemID (@ConfigItemIDs) {
+ 
+             # get the last version of this config item
+             $Self->{DBObject}->Prepare(
+                 SQL => "SELECT id FROM configitem_version "
+                     . "WHERE configitem_id = $ConfigItemID ORDER BY id DESC",
+                 Limit => 1,
+             );
+ 
+             # fetch the result
+             my $VersionID;
+             while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
+                 $VersionID = $Row[0];
+             }
+ 
+             next CONFIGITEMID if !$VersionID;
+ 
+             # update inci_state_id
+             $Self->{DBObject}->Do(
+                 SQL => "UPDATE configitem "
+                     . "SET last_version_id = $VersionID "
+                     . "WHERE id = $ConfigItemID",
+             );
+         }
+     }
+ 
      # WORKAROUND: set empty inci_state_id in configitem_version table
      {
***************
*** 288,291 ****
--- 330,334 ----
      $ConfigItem{ClassID}
      $ConfigItem{Class}
+     $ConfigItem{LastVersionID}
      $ConfigItem{CurDeplStateID}
      $ConfigItem{CurDeplState}
***************
*** 329,333 ****
      # ask database
      $Self->{DBObject}->Prepare(
!         SQL => "SELECT id, configitem_number, class_id, cur_depl_state_id, cur_inci_state_id, "
              . "create_time, create_by, change_time, change_by "
              . "FROM configitem WHERE id = $Param{ConfigItemID}",
--- 372,377 ----
      # ask database
      $Self->{DBObject}->Prepare(
!         SQL => "SELECT id, configitem_number, class_id, last_version_id, "
!             . "cur_depl_state_id, cur_inci_state_id, "
              . "create_time, create_by, change_time, change_by "
              . "FROM configitem WHERE id = $Param{ConfigItemID}",
***************
*** 341,350 ****
          $ConfigItem{Number}         = $Row[1];
          $ConfigItem{ClassID}        = $Row[2];
!         $ConfigItem{CurDeplStateID} = $Row[3];
!         $ConfigItem{CurInciStateID} = $Row[4];
!         $ConfigItem{CreateTime}     = $Row[5];
!         $ConfigItem{CreateBy}       = $Row[6];
!         $ConfigItem{ChangeTime}     = $Row[7];
!         $ConfigItem{ChangeBy}       = $Row[8];
      }
  
--- 385,395 ----
          $ConfigItem{Number}         = $Row[1];
          $ConfigItem{ClassID}        = $Row[2];
!         $ConfigItem{LastVersionID}  = $Row[3];
!         $ConfigItem{CurDeplStateID} = $Row[4];
!         $ConfigItem{CurInciStateID} = $Row[5];
!         $ConfigItem{CreateTime}     = $Row[6];
!         $ConfigItem{CreateBy}       = $Row[7];
!         $ConfigItem{ChangeTime}     = $Row[8];
!         $ConfigItem{ChangeBy}       = $Row[9];
      }
  
***************
*** 537,543 ****
  =item ConfigItemSearchExtended()
  
! return a config item list as array reference
  
!     my $ConfigItemListRef = $ConfigItemObject->ConfigItemSearchExtended(
          ClassIDs        => [9, 8, 7, 6],                         # (optional)
          CurDeplStateIDs => [1, 2, 3, 4],                         # (optional)
--- 582,588 ----
  =item ConfigItemSearchExtended()
  
! return a config item list as an array reference
  
!     my $ConfigItemIDs = $ConfigItemObject->ConfigItemSearchExtended(
          ClassIDs        => [9, 8, 7, 6],                         # (optional)
          CurDeplStateIDs => [1, 2, 3, 4],                         # (optional)
***************
*** 601,605 ****
  
      # version search is required if 'Name' is given
!     if ( $Param{Name} ) {
          $RequiredSearch{Version} = 1;
      }
--- 646,650 ----
  
      # version search is required if 'Name' is given
!     if ( $Param{Name} || $Param{PreviousVersionSearch} ) {
          $RequiredSearch{Version} = 1;
      }
***************
*** 702,708 ****
  =item ConfigItemSearch()
  
! return a config item list as array reference
  
!     my $ConfigItemListRef = $ConfigItemObject->ConfigItemSearch(
          Number          => 'The ConfigItem Number',  # (optional)
          ClassIDs        => [9, 8, 7, 6],             # (optional)
--- 747,753 ----
  =item ConfigItemSearch()
  
! return a config item list as an array reference
  
!     my $ConfigItemIDs = $ConfigItemObject->ConfigItemSearch(
          Number          => 'The ConfigItem Number',  # (optional)
          ClassIDs        => [9, 8, 7, 6],             # (optional)
***************
*** 722,727 ****
          ConfigItemChangeTimeOlderDate => '2006-01-19 23:59:59',  # (optional)
  
!         OrderBy        => 'Number',  # (optional) default ID
!         # (ID, Number, CurDeplStateID, CurInciStateID, CreateTime, CreateBy, ChangeTime, ChangeBy)
  
          Limit          => 122,  # (optional)
--- 767,773 ----
          ConfigItemChangeTimeOlderDate => '2006-01-19 23:59:59',  # (optional)
  
!         OrderBy => 'Number',  # (optional) default ConfigItemID
!         # (ConfigItemID, Number, ClassID, CurDeplStateID, CurInciStateID,
!         # CreateTime, CreateBy, ChangeTime, ChangeBy)
  
          Limit          => 122,  # (optional)
***************
*** 734,738 ****
      my ( $Self, %Param ) = @_;
  
!     # set default value
      if ( !defined $Param{UsingWildcards} ) {
          $Param{UsingWildcards} = 1;
--- 780,784 ----
      my ( $Self, %Param ) = @_;
  
!     # set default values
      if ( !defined $Param{UsingWildcards} ) {
          $Param{UsingWildcards} = 1;
***************
*** 740,747 ****
      $Param{OrderBy} ||= 'id';
  
-     # sql where array
-     my @SQLWhere;
- 
      # add number to sql where array
      if ( $Param{Number} ) {
  
--- 786,791 ----
      $Param{OrderBy} ||= 'id';
  
      # add number to sql where array
+     my @SQLWhere;
      if ( $Param{Number} ) {
  
***************
*** 828,833 ****
      # define order table
      my %OrderByTable = (
!         ID             => 'id',
          Number         => 'configitem_number',
          CurDeplStateID => 'cur_depl_state_id',
          CurInciStateID => 'cur_inci_state_id',
--- 872,878 ----
      # define order table
      my %OrderByTable = (
!         ConfigItemID   => 'id',
          Number         => 'configitem_number',
+         ClassID        => 'class_id',
          CurDeplStateID => 'cur_depl_state_id',
          CurInciStateID => 'cur_inci_state_id',
***************
*** 839,843 ****
  
      # set order by
!     my $OrderBy = $OrderByTable{ $Param{OrderBy} } || $OrderByTable{ID};
  
      # set limit
--- 884,888 ----
  
      # set order by
!     my $OrderBy = $OrderByTable{ $Param{OrderBy} } || $OrderByTable{ConfigItemID};
  
      # set limit


More information about the cvs-log mailing list