Simple Machines Community Forum

SMF Development => Bug Reports => Topic started by: Randem on February 15, 2014, 02:17:26 AM

Title: Profile Fields - Names truncated in the Themes table
Post by: Randem on February 15, 2014, 02:17:26 AM
I just started using Custom Profile Fields and every name over 6 characters is truncated in the Themes table (variable column) after the system prefixes the name with "cust_". This is happening even though the variable field in the Themes table is defined as varchar (255). The system will also add a zero after truncation if the name is duplicated after truncation.  ???

cust_zip - Originally defined as "zip"
cust_zip0 - Originally defined as "zip+4" or "zip_4"

cust_deceas - Originally defined as "deceased"
cust_deceas0 - Originally defined as "deceased_date"

The reason this is a problem is I am porting information from another system into SMF and it would help if the names did not change from the original names entered. :(

What is the reason for the truncation to 6 characters??? How can I overcome this issue?

I am using SMF 2.0.7. Have not tested SMF 2.0.6...
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: Randem on February 15, 2014, 03:13:29 AM
Did some more research and found that the custom_fields table has a column named "col_name" which is defined as varchar(12). Is there a reason that this field is so small (legacy). What are the ramifications of changing this field length to a bigger number say 30-50?
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: margarett on February 15, 2014, 04:36:27 AM
It's not a bug, it's a feature :P Why, I don't know...

It has 2 places to being changed: the "custom_fields" table where the field is defined, and the "themes" table where the actual member values are stored.
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: Randem on February 15, 2014, 04:40:31 AM
Yeah  8), I changed the field length and no Joy. There has to be something in the code that truncates the field... Looking for it now...

Odd thing is that it is varchar(255) in Themes...
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: Randem on February 15, 2014, 04:58:31 AM
Found the change area in ManageSettings.php line 1705. Changed

$colname = $smcFunc['substr'](strtr($_POST['field_name'], array(' ' => '')), 0, 6);

to

$colname = $smcFunc['substr'](strtr($_POST['field_name'], array(' ' => '')), 0, 50);

and changed the table "custom_fields" field name "col_name" to varchar(50). Ths allowed the full name to be entered into the column.

Thanks for the verification.
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: margarett on February 15, 2014, 07:36:56 AM
Quote from: Randem on February 15, 2014, 04:40:31 AM
Odd thing is that it is varchar(255) in Themes...
That's because the column is generic, it stores values from several other fields
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: Randem on February 15, 2014, 02:10:29 PM
Yes I know... The point I was attempting t make was that the definitions went from minimal (12) to overkill (255) for field lengths. I don't remember when the last time a 12 character field name was used. I believe it was in the 80's in COBOL... ::) (8 character filename and a 3 character extension)  :o
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: Oldiesmann on February 15, 2014, 05:04:45 PM
To be honest I've never understood why SMF picks the "name" for that field anyway. It seems like it would make more sense to allow the user to pick that (while still adding "cust_" to the beginning to prevent conflicts), especially for site integration purposes. Maybe this is something we can change for 2.1.
Title: Re: Profile Fields - Names truncated in the Themes table
Post by: Randem on February 15, 2014, 05:09:03 PM
Actually SMF does allow the user to pick the name but then SMF proceeds to bastardize the name for no apparent reason. Legacy name conventions have not been really used for about 20 years now. No reason for 8.3 naming conventions...

SMF's intention was to eliminate duplicate field names...