View Issue Details

IDProjectCategoryView StatusLast Update
0008017mantisbtadministrationpublic2016-06-11 11:44
Reporterlibregeek Assigned Todregad  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Target Version1.3.0-beta.1Fixed in Version1.3.0-beta.1 
Summary0008017: Increase the size of the username field
Description

The username field in mantis is limited to 32 characters in the database and in the corresponding text boxes. This makes difficult for administrators who uses email as the username for mantis. In my case, I am using ldap uids which are of the form firstname.lastname@domain.tld, which generally has more than 50 characters. It would be nice if the username field size is increased to 64 characters(VARCHAR).

Additional Information

These are the list of changes to be done to attain the above feature.
Database modification:
mysql> alter table mantis_user_table change username username varchar(64);

Source code changes(filenames)

mantis/manage_user_create.php
mantis/manage_user_edit.php
mantis/login_page.php
mantis/core/user_api.php

Tagspatch
Attached Files
username_field-1.1.6.patch (2,628 bytes)   
diff -ur mantisbt-1.1.6/admin/schema.php mantis/admin/schema.php
--- mantisbt-1.1.6/admin/schema.php	2008-12-09 14:20:28.000000000 -0500
+++ mantis/admin/schema.php	2009-01-12 04:34:36.000000000 -0500
@@ -303,7 +303,7 @@
 ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_user_table'),"
   id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  username 		C(32) NOTNULL DEFAULT \" '' \",
+  username 		C(255) NOTNULL DEFAULT \" '' \",
   realname 		C(64) NOTNULL DEFAULT \" '' \",
   email 		C(64) NOTNULL DEFAULT \" '' \",
   password 		C(32) NOTNULL DEFAULT \" '' \",
diff -ur mantisbt-1.1.6/core/user_api.php mantis/core/user_api.php
--- mantisbt-1.1.6/core/user_api.php	2008-12-09 14:20:28.000000000 -0500
+++ mantis/core/user_api.php	2009-01-12 04:26:13.000000000 -0500
@@ -217,7 +217,7 @@
 	# Return true if it is, false otherwise
 	function user_is_name_valid( $p_username ) {
 		# The DB field is only 32 characters
-		if ( strlen( $p_username ) > 32 ) {
+		if ( strlen( $p_username ) > 255 ) {
 			return false;
 		}
 
diff -ur mantisbt-1.1.6/login_page.php mantis/login_page.php
--- mantisbt-1.1.6/login_page.php	2008-12-09 14:20:29.000000000 -0500
+++ mantis/login_page.php	2009-01-12 04:25:23.000000000 -0500
@@ -98,7 +98,7 @@
 		<?php echo lang_get( 'username' ) ?>
 	</td>
 	<td width="75%">
-		<input type="text" name="username" size="32" maxlength="32" />
+		<input type="text" name="username" size="32" maxlength="255" />
 	</td>
 </tr>
 <tr class="row-2">
diff -ur mantisbt-1.1.6/manage_user_create_page.php mantis/manage_user_create_page.php
--- mantisbt-1.1.6/manage_user_create_page.php	2008-12-09 14:20:29.000000000 -0500
+++ mantis/manage_user_create_page.php	2009-01-12 04:24:30.000000000 -0500
@@ -47,7 +47,7 @@
 		<?php echo lang_get( 'username' ) ?>
 	</td>
 	<td width="75%">
-		<input type="text" name="username" size="32" maxlength="32" />
+		<input type="text" name="username" size="32" maxlength="255" />
 	</td>
 </tr>
 <tr <?php echo helper_alternate_class() ?>>
diff -ur mantisbt-1.1.6/manage_user_edit_page.php mantis/manage_user_edit_page.php
--- mantisbt-1.1.6/manage_user_edit_page.php	2008-12-09 14:20:29.000000000 -0500
+++ mantis/manage_user_edit_page.php	2009-01-12 04:24:52.000000000 -0500
@@ -60,7 +60,7 @@
 		<?php echo lang_get( 'username' ) ?>:
 	</td>
 	<td width="70%">
-		<input type="text" size="16" maxlength="32" name="username" value="<?php echo $t_user['username'] ?>" />
+		<input type="text" size="16" maxlength="255" name="username" value="<?php echo $t_user['username'] ?>" />
 	</td>
 </tr>
 
username_field-1.1.6.patch (2,628 bytes)   
username-trunk.patch (1,153 bytes)   
diff --git a/admin/schema.php b/admin/schema.php
index cc687f2..fd51f70 100644
--- a/admin/schema.php
+++ b/admin/schema.php
@@ -298,7 +298,7 @@ $upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_profile_tabl
 ",Array('mysql' => 'ENGINE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
 $upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_user_table'),"
   id 			 I  UNSIGNED NOTNULL PRIMARY AUTOINCREMENT,
-  username 		C(32) NOTNULL DEFAULT \" '' \",
+  username 		C(255) NOTNULL DEFAULT \" '' \",
   realname 		C(64) NOTNULL DEFAULT \" '' \",
   email 		C(64) NOTNULL DEFAULT \" '' \",
   password 		C(32) NOTNULL DEFAULT \" '' \",
diff --git a/core/constant_inc.php b/core/constant_inc.php
index 9d8d85e..7a444db 100644
--- a/core/constant_inc.php
+++ b/core/constant_inc.php
@@ -474,6 +474,6 @@ define( 'PHPMAILER_METHOD_SENDMAIL',	1 );
 define( 'PHPMAILER_METHOD_SMTP',		2 );
 
 # Lengths - NOTE: these may represent hard-coded values in db schema and should not be changed.
-define( 'USERLEN', 32);
+define( 'USERLEN', 255);
 define( 'REALLEN', 64);
-define( 'PASSLEN', 32);
\ No newline at end of file
+define( 'PASSLEN', 32);
username-trunk.patch (1,153 bytes)   

Relationships

has duplicate 0013478 closedatrol max username size (32 char) is too small 
has duplicate 0008596 closedatrol Unable to log in using username with more than 32 characters 
related to 0020431 assigneddregad Use utf8mb4 charset for new MySQL installations 
related to 0020465 closeddregad Reduce size of username and email fields to allow utf8mb4 charset 

Activities

vboctor

vboctor

2007-06-09 13:09

manager   ~0014736

The size of the field in the database also needs to be changed. If we are going to increase the field size, then we should increase it to the maximum size of an email address as per RFC or the maximum size allowed for a db varchar field. So, I would suggest 250.

libregeek

libregeek

2007-06-27 08:04

reporter   ~0014826

RFC 2821 (http://tools.ietf.org/html/rfc2821) specifies that the local part of the email address can ne upto 64 characters and the domain part upto 255 characters. Combining these two will make up 319characters which may not be necessary in the near future.
So I would also suggest to use the maximum allowed size of a database VARCHAR field. I think that the maximum allowed sixe(in MySQL) is 255, am I right?

libregeek

libregeek

2009-01-12 04:51

reporter   ~0020586

I have created a patch for increasing the size of username field in mantis-1.1.6. Please verify and commit if it makes sense. This patch will increase the size of the username field to 255 characters.

siebrand

siebrand

2009-01-12 18:06

developer   ~0020594

Please update patch to be based on trunk.

libregeek

libregeek

2009-01-13 01:34

reporter   ~0020598

I'm confused on how to get the source code from the git repository. It seems the documentation in http://www.mantisbt.org/development.php doesn't have enough information about git. Please help.

siebrand

siebrand

2009-01-13 01:53

developer   ~0020599

Yeah, I was a bit confused, too. Still learning GIT and I have access to the master repo, so didn't know about the public repo. See http://www.mantisforge.org/development for details.

libregeek

libregeek

2009-01-13 02:31

reporter   ~0020600

Here is a quick patch from trunk. I'm a beginner in GIT, please guide me if something have gone wrong.

ubuone

ubuone

2011-11-03 05:59

reporter   ~0030152

Hi, to increase the username max size on an existing installation of mantis, you just have to increase the username database field to 255 (for example) and to create a custom_constants_inc.php file with :
<?php define( 'DB_FIELD_SIZE_USERNAME', 255);
The rest is cosmetic (html input size).
Am I right ?

anabuki

anabuki

2012-01-25 17:44

reporter   ~0031037

I am running Mantis version 1.2.8, and, as far as I have been able to perceive, the changes on the files described here are not required anymore. The files have already been updated to use a constant.

To change the size of the login field, you just need to edit the column "username" in the table "bugtracker.mantis_user_table" to the required size and then, change the constant "DB_FIELD_SIZE_USERNAME" in the file "core/constant_inc.php".

In my case, I changed the column to varchar(64) and changed the constant size to 64. And now I can create longer usernames. =)

Ps.: Just adding this comment, so that people may know how to change the username size in the new versions of Mantis.

vboctor

vboctor

2012-01-27 12:39

manager   ~0031060

The change to the schema file is incorrect. What you should do is add a step to the end of the schema that change the size of the username field. This way, the upgrade path works as well, and not just the new installs. In other words, the schema file should create the username with the old size, then make it larger at the end.

I would also suggest that you try using github.com to fork the code, apply your change, and then submit a pull request. This will make the process as efficient as possible.

grangeway

grangeway

2012-02-05 07:31

reporter   ~0031126

fixed in next branch

libregeek

libregeek

2012-02-06 00:02

reporter   ~0031165

@grangeway
Could you please post the changeset id?

atrol

atrol

2012-03-14 18:26

developer   ~0031467

Reopened, there is no "Fixed in Version" and we will have no "Roadmap" and
"Changelog". There is no patch / changeset attached which will confuse any user
who has a look at this issue.

ubuone

ubuone

2012-04-18 10:46

reporter   ~0031685

In mantisbt 1.2.9 the size of the column "username" is 255.
But the max length of the field in the html form is limited to 32 char.
This lentgh can be modified with the constant "DB_FIELD_SIZE_USERNAME" in the file "core/constant_inc.php".
Is it possible to define this size in a user file like custom_constants_inc.php ?

atrol

atrol

2012-04-18 10:57

developer   ~0031686

ubuone wrote

In mantisbt 1.2.9 the size of the column "username" is 255.

This is not true, it's still 32.

ubuone

ubuone

2012-04-20 16:38

reporter   ~0031699

Sorry, my mistake !

ubuone

ubuone

2014-05-22 08:35

reporter   ~0040621

Hi,
in mantisbt 1.3.0dev username size is still 32, could it be increased to 255 ?

dregad

dregad

2014-07-17 03:35

developer   ~0040933

https://github.com/mantisbt/mantisbt/pull/235

Related Changesets

MantisBT: master d103c028

2014-05-22 08:36

dregad

Committer: Paul Richards


Details Diff
Fix 0008017: allow username up to 255 chars

Signed-off-by: Paul Richards <paul@mantisforge.org>
Affected Issues
0008017
mod - admin/schema.php Diff File
mod - core/constant_inc.php Diff File

MantisBT: master ecd12610

2015-12-30 14:03

dregad


Details Diff
Reduce user.username column size to 191 chars

The varchar(255) implemented to address issue 0008017 was causing issues
with utf8mb4 encoding due a limitation in the size of indexes in MySQL.

Fixes 0020465
Affected Issues
0008017, 0020465
mod - admin/schema.php Diff File
mod - core/constant_inc.php Diff File

MantisBT: master 76cb1ad2

2015-12-30 14:03

dregad


Details Diff
Reduce email and realname columns to 191 chars

The varchar(255) implemented to address issue 0008017 was causing issues
with utf8mb4 encoding due a limitation in the size of indexes in MySQL.

Fixes 0020465
Affected Issues
0008017, 0020465
mod - admin/schema.php Diff File