[Rt-commit] rt branch 5.0/shred-attachments-fts-index created. rt-5.0.4-18-gb6487b80f5

BPS Git Server git at git.bestpractical.com
Wed May 24 05:40:10 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/shred-attachments-fts-index has been created
        at  b6487b80f52f88347a927d502d65556c544437b0 (commit)

- Log -----------------------------------------------------------------
commit b6487b80f52f88347a927d502d65556c544437b0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 24 08:39:52 2023 +0300

    stab

diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 2c50447a91..08466e54d4 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -1345,6 +1345,19 @@ sub __DependsOn {
     );
     push( @$list, $objs );
 
+    # fulltext index
+    my $fts = RT->Config->Get('FullTextSearch');
+    if ( $fts && $fts->{Indexed} && $fts->{Table} ) {
+        require RT::Shredder::RawRecord;
+        push @$list, RT::Shredder::RawRecord->new(
+            CurrentUser => $self->CurrentUser,
+            Table => $fts->{Table},
+            Columns => {
+                id => $self->Id,
+            },
+        );
+    }
+
     $deps->_PushDependencies(
         BaseObject => $self,
         Flags => RT::Shredder::Constants::DEPENDS_ON,
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 6baaf42e30..f5bf64d6eb 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -351,6 +351,8 @@ sub CastObjectsToRecords
         while( my $tmp = $targets->Next ) { push @res, $tmp };
     } elsif ( UNIVERSAL::isa( $targets, 'RT::Record' ) ) {
         push @res, $targets;
+    } elsif ( UNIVERSAL::isa( $targets, 'RT::Shredder::RawRecord' ) ) {
+        push @res, $targets;
     } elsif ( UNIVERSAL::isa( $targets, 'ARRAY' ) ) {
         foreach( @$targets ) {
             push @res, $self->CastObjectsToRecords( Objects => $_ );
diff --git a/lib/RT/Shredder/RawRecord.pm b/lib/RT/Shredder/RawRecord.pm
new file mode 100644
index 0000000000..05b9a09341
--- /dev/null
+++ b/lib/RT/Shredder/RawRecord.pm
@@ -0,0 +1,99 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC
+#                                          <sales at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+
+package RT::Shredder::RawRecord;
+
+use strict;
+use warnings FATAL => 'all';
+
+sub new
+{
+    my $proto = shift;
+    my $self = bless( {}, ref $proto || $proto );
+    $self->Set( @_ );
+    return $self;
+}
+
+sub Set
+{
+    my $self = shift;
+    my %args = ( @_ );
+    my @keys = qw(Table Columns);
+    @$self{ @keys } = @args{ @keys };
+
+    return;
+}
+
+sub _AsInsertQuery
+{
+    my $self = shift;
+
+    my $dbh = $RT::Handle->dbh;
+
+    my $res = "INSERT INTO ". $self->Table;
+    my $values = $self->{'values'};
+    $res .= "(". join( ",", map { $dbh->quote_identifier( $_ ) } sort keys %$values ) .")";
+    $res .= " VALUES";
+    $res .= "(". join( ",", map { $dbh->quote( $values->{$_} ) } sort keys %$values ) .")";
+    $res .= ";";
+
+    return $res;
+}
+
+sub BeforeWipeout {
+    return 1;
+}
+
+sub __DependsOn
+{
+    return;
+}
+
+sub Table { return $_[0]->{'Table'} }
+
+1;
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list