Gossamer Forum
Home : Products : Gossamer Links : Discussions :

[Bug ?] : Not Null seems to be not working

Quote Reply
[Bug ?] : Not Null seems to be not working
Below are the settings I am using, however for some reason "Not Null" function does not seem to work and still accepts the input.


Column Name Support_Email
Column Type : VARCHAR
Column Index : None
Column Size : 150
Not Null : Yes
Default : testemail@domain.com
Form Display : Support_Email
Form Type : Text
Form Size : 50

Everything else is left Blank.
========================

Now from admin side when I modify existing user and leave Support_Email field empty it does not give any error and simply accepts the form input.

Any idea on how to fix this issue?

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
Hi,

In that case, the value will be ' testemail@domain.com'(the default one) so that mysql/glinks won't show the error.

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] [Bug ?] : Not Null seems to be not working In reply to
tandat wrote:
Hi,

In that case, the value will be ' testemail@domain.com'(the default one) so that mysql/glinks won't show the error.

I was assuming the same, however that does not seem to be case.

1. I tried editing profile from admin view and left Support_Email empty. GLinks system accepted the profile edit and now when I view the profile Support_Email field shows empty. (It should not have allowed me to leave the field empty)

2. From public view I edited the profile (after logging into specific test account) and edited profile and left Support_Email empty - Same results as above. I see success page and I was able to setup profile without Support_Email field.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
That sounds strange. Did you 'resync' the table and mysql?

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] [Bug ?] : Not Null seems to be not working In reply to
tandat wrote:
That sounds strange. Did you 'resync' the table and mysql?

Yeah did both but still seeing the same error :(

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
Anyone got any idea??

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
It should give you a not null error. No clue why it isn't. Perhaps you have a plugin that's doing something with the value. Is it just being saved as empty string?

Adrian
Quote Reply
Re: [brewt] [Bug ?] : Not Null seems to be not working In reply to
Hum.. for whatever reason it is not trying to validate other fields too. I have another Radio field with option Yes/No. However it is still allowing successfully form submit without any error display :(

Here is the list of installed plug-in on the site:

Days_Old
ExtraStats
SiteStats
StaticURLtr
ULTRAGlobals
User_Edit_Profile

Please Help ! :(

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
Try disabling ALL the plugin hooks ( via "edit" on each plugin), and then add another record. If you add it, and does exactly the same thing - then it must be glinks related.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [Bug ?] : Not Null seems to be not working In reply to
Hey Andy, Thanks for the input.

Quote:
Try disabling ALL the plugin hooks ( via "edit" on each plugin), and then add another record. If you add it, and does exactly the same thing
Just did that.
But no success. Also for testing purpose I actually created new field and tried it, but form still accepts the submission without any input in required field :(

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
Ok, so sounds like it may be a bug then Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [Bug ?] : Not Null seems to be not working In reply to
It's not GT::SQL. Tests run fine and I just tested on my install - it gives the correct not null error.

Adrian
Quote Reply
Re: [brewt] [Bug ?] : Not Null seems to be not working In reply to
Well after your post, I just did another testing and here is an odd error.

1. When I try to create new user (since I set those properties under user table), it tell me that the field is required and can't be left blank
2. So I created new user and had all valid inputs and the form was accepted - as it should.

3. However then I fired up the form again (admin view) and modified the same user, however this time I removed the info and on purpose left the field empty.

And the form was accepted with any error.

Vishal
-------------------------------------------------------
Quote Reply
Re: [brewt] [Bug ?] : Not Null seems to be not working In reply to
Hi Adrian,

Any thoughts on this possible GLinks Bug?

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
Hi Adrian,

If you or someone at GT can look into this bug, it would be much appreciated.

Thank you.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [Bug ?] : Not Null seems to be not working In reply to
Oh, it only happens with the User table, not other tables. That's one really old bug. It was broken 8 and a half years ago! I'll see about a fix tomorrow.

Adrian
Quote Reply
Re: [brewt] [Bug ?] : Not Null seems to be not working In reply to
hahah - don't you just love bugs that pop their ugly head up =) Had it a few times in my plugins (either it gets removed by accident, when you don't use the latest version when adding fixes - or you break the fix when making more changs =)). The joys of coding :D

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [brewt] [Bug ?] : Not Null seems to be not working In reply to
Try this patch:
Code:
--- admin/Links/Table/Users.pm 12 May 2005 20:51:24 -0000 1.5
+++ admin/Links/Table/Users.pm 10 Jul 2009 09:25:48 -0000
@@ -35,7 +35,6 @@
return 1;
}

-
sub add {
# -------------------------------------------------------------------
my ($self, @args) = @_;
@@ -103,48 +102,38 @@
sub _plg_modify {
# -------------------------------------------------------------------
init();
- my $self = shift;
+ my $self = shift;
my $input = $self->common_param(@_) or return $self->error('BADARGS', 'FATAL', '$obj->insert(HASH or HASH_REF or CGI) only.');
- my $id = $input->{Username} or return $self->error("BADARGS", "FATAL", "No primary key passed to modify!");
- my $sth = $self->select('Username', 'Password', { Username => $id });
- my $rec = $sth->fetchrow_hashref;
- if ($rec) {
- if ($input->{Password} ne $rec->{Password}) {
- Links::Authenticate::auth('change_pass', { Username => $rec->{Username}, Password => $rec->{Password}, New_Password => $input->{Password} })
- or return $self->error('AUTHERROR', 'WARN', $Links::Authenticate::error);
- }
- }

-# Connect to the database if we are not already connected
- $self->connect;
+# Unfortunately, the Username column is the primary key, so hackery is needed
+# to change the username.
+ my $new_id = $input->{Username};
+ my $old_id = $input->{orig_username};
+ $old_id = $new_id unless length $old_id;

-# Copy the data and remove anything that doesn't make sense here.
- my $c = $self->{schema}->{cols};
- my $set = {};
- for (keys %$c) {
- $set->{$_} = $input->{$_} if exists $input->{$_};
- }
-
-# Remove primary keys from update clause.
- my $where;
- if ($input->{orig_username}) {
- $where->{Username} = $input->{orig_username};
- }
- else {
- foreach my $key (@{$self->{schema}->{pk}}) {
- $where->{$key} = delete $set->{$key} if exists $set->{$key};
- }
+ return $self->error("BADARGS", "FATAL", "No primary key passed to modify!") unless $old_id;
+
+ my $rec = $self->select('Username', 'Password', { Username => $old_id })->fetchrow_hashref;
+ return $self->error('BADARGS', 'FATAL', 'Non-existent primary key passed to modify!') unless $rec;
+
+ if ($input->{Password} ne $rec->{Password}) {
+ Links::Authenticate::auth('change_pass', { Username => $rec->{Username}, Password => $rec->{Password}, New_Password => $input->{Password} })
+ or return $self->error('AUTHERROR', 'WARN', $Links::Authenticate::error);
}
- return $self->error("NOPKTOMOD", "WARN") unless keys %$where == @{$self->{schema}->{pk}};

-# Remove timestamps - no sense updating.
- $self->_check_timestamp($where, $set) or return;
- foreach my $col (keys %$c) {
- delete $set->{$col} if $c->{$col}->{type} eq 'TIMESTAMP';
+# Check for Username uniqueness if it's changing.
+ if ($new_id ne $old_id) {
+ return $self->error('UNIQUE', 'WARN', 'Username', $new_id) if $self->count({ Username => $new_id });
+ $input->{Username} = $old_id;
}

-# Execute the update
- $self->update($set, $where) or return;
+ $self->SUPER::modify($input) or return;
+
+ if ($new_id ne $old_id) {
+ $self->update({ Username => $new_id }, { Username => $old_id }) or return;
+# Restore Username as the caller might need it (hashref).
+ $input->{Username} = $new_id;
+ }
return 1;
}

Adrian
Quote Reply
Re: [brewt] [Bug ?] : Not Null seems to be not working In reply to
Hi Adrian,

This fix is going to be available in the next update (auto update or release) of GLinks, right?

Thanks.

Vishal
-------------------------------------------------------