[dw-free] Make sitekeywords table case sensitive
[commit: http://hg.dwscoalition.org/dw-free/rev/45b3c265fe97]
http://bugs.dwscoalition.org/show_bug.cgi?id=3174
Allow mixed case for sitekeywords.
Patch by
exor674.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3174
Allow mixed case for sitekeywords.
Patch by
Files modified:
- bin/upgrading/update-db-general.pl
- cgi-bin/DW/VirtualGift.pm
- cgi-bin/ljlib.pl
--------------------------------------------------------------------------------
diff -r 9b600c7ae8fc -r 45b3c265fe97 bin/upgrading/update-db-general.pl
--- a/bin/upgrading/update-db-general.pl Thu Oct 28 08:19:28 2010 -0500
+++ b/bin/upgrading/update-db-general.pl Fri Oct 29 13:47:24 2010 +0800
@@ -2997,7 +2997,7 @@ register_tablecreate('sitekeywords', <<'
register_tablecreate('sitekeywords', <<'EOC');
CREATE TABLE sitekeywords (
kwid INT(10) UNSIGNED NOT NULL,
- keyword VARCHAR(255) NOT NULL,
+ keyword VARCHAR(255) BINARY NOT NULL,
PRIMARY KEY (kwid),
UNIQUE KEY (keyword)
@@ -3917,6 +3917,11 @@ EOF
}
}
+ unless ( column_type( 'sitekeywords', 'keyword' ) =~ /BINARY/ ) {
+ do_alter( 'sitekeywords',
+ q{ALTER TABLE sitekeywords MODIFY keyword VARCHAR(255) BINARY NOT NULL} );
+ }
+
});
diff -r 9b600c7ae8fc -r 45b3c265fe97 cgi-bin/DW/VirtualGift.pm
--- a/cgi-bin/DW/VirtualGift.pm Thu Oct 28 08:19:28 2010 -0500
+++ b/cgi-bin/DW/VirtualGift.pm Fri Oct 29 13:47:24 2010 +0800
@@ -290,7 +290,7 @@ sub tags {
foreach my $tag ( @valid_tags ) {
next if $dbtags{$tag};
# try to create the tag if it didn't already exist
- my $tagid = LJ::get_sitekeyword_id( $tag, $autovivify );
+ my $tagid = LJ::get_sitekeyword_id( $tag, $autovivify, allowmixedcase => 1 );
return $error->( LJ::Lang::ml( 'vgift.error.tags.create',
{ tag => LJ::ehtml( $tag ) } ) ) unless $tagid;
$dbtags{$tag} = $tagid;
@@ -387,7 +387,7 @@ sub alter_tag {
sub create_tag {
my ( $self, $tagname ) = @_;
- return LJ::get_sitekeyword_id( $tagname, 1 );
+ return LJ::get_sitekeyword_id( $tagname, 1, allowmixedcase => 1 );
}
sub _addremove_tagpriv {
@@ -559,7 +559,7 @@ sub img_mogkey {
# tagnames and interests are both in sitekeywords
sub get_tagname { return LJ::get_interest( $_[1] ) }
-sub get_tagid { return LJ::get_sitekeyword_id( $_[1], 0 ) }
+sub get_tagid { return LJ::get_sitekeyword_id( $_[1], 0, allowmixedcase => 1 ) }
sub can_be_approved_by {
my ( $self, $u ) = @_;
diff -r 9b600c7ae8fc -r 45b3c265fe97 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl Thu Oct 28 08:19:28 2010 -0500
+++ b/cgi-bin/ljlib.pl Fri Oct 29 13:47:24 2010 +0800
@@ -1524,13 +1524,13 @@ sub get_interest {
# style -- yes, do automatically create the keyword.
# </LJFUNC>
sub get_sitekeyword_id {
- my ( $kw, $autovivify ) = @_;
+ my ( $kw, $autovivify, %opts ) = @_;
$autovivify = 1 unless defined $autovivify;
# setup the keyword for use
return 0 unless $kw =~ /\S/;
$kw = LJ::trim( LJ::text_trim( LJ::trim( $kw ), LJ::BMAX_SITEKEYWORD, LJ::CMAX_SITEKEYWORD ) );
- $kw = LJ::utf8_lc( $kw );
+ $kw = LJ::utf8_lc( $kw ) unless $opts{allowmixedcase};
# get the keyword and insert it if necessary
my $dbr = LJ::get_db_reader();
--------------------------------------------------------------------------------
