Hi :)

In the anonymous posting field type, it has name, mail, homepage, hostname colume.
Well.. email field length is limited to 64. I think it's too short. some email addresses are long over 64 characters.

At least, it must same with drupal's user email length (254).
How about thinks you?

Comments

drikc’s picture

I don't have much thought about this; I've just used the same one found in the comment module! I you really need I could change that length or also if you want to contribute to this with a patch you are welcome. Let me know.

yashadev’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new1.15 KB

Here's a quick patch to extend the email length

yashadev’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.15 KB

Here's a quick patch to extend the email length

drikc’s picture

Hello, the patch extend the input html tag length to 255 but steel the storage schema definition is set to 64. Also some care must be taken with installed module, i.e., in a hook_update_N() to alter that schema.

drikc’s picture

Status: Needs review » Needs work
yashadev’s picture

Assigned: Unassigned » yashadev
Status: Needs work » Needs review
StatusFileSize
new1.86 KB

This should fix the problem. Let me know after testing

drikc’s picture

Status: Needs review » Needs work

There is steel an update_hook_N to be done to update existing schema to 254 length.

yashadev’s picture

Status: Needs work » Needs review
StatusFileSize
new2.31 KB

Here you go. This should work.

Please read the following guidelines for the email length:
According to RFC 5322, RFC 5321, and RFC 3696, (http://en.wikipedia.org/wiki/Email_address#Syntax),

The format of email addresses is local-part@domain where the local-part may be up to 64 characters long and the domain name may have a maximum of 253 characters - but the maximum 256 characters length of a forward or reverse path restricts the entire email address to be no more than 254 characters.

So the email format should be [64 chars max]@[253 chars max] with the total length of 254 chars.

The patch is written so the database is set to 255 chars because the standard databases are set to use 255 chars maximum; therefore, using 254 chars would probably slow down the process.

drikc’s picture

Status: Needs review » Needs work

I can see in your update_hook_N() the following line:

  db_change_field($columns['mail'], 'mail', 'mail', $mail_field, array('indexes' => array('mail' => array('mail'))));

It will fail because the '$columns['mail'] is unset!

yashadev’s picture

StatusFileSize
new9.55 KB

It runs without giving any errors and sets the database to the correct varchar length.. What should it be set to then?
I've tested the patch to check if the email is being passed to the database and whether the article is submitted or not. It all worked out well.

drikc’s picture

StatusFileSize
new15.24 KB

Here is your full hook_update_N():

function anonymous_posting_field_update_7102() {
 $mail_field = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => FALSE,
    'default' => '',
    'description' => "User's e-mail address.",
  );

  db_change_field($columns['mail'], 'mail', 'mail', $mail_field, array('indexes' => array('mail' => array('mail'))));
}

This code for sure didn't change any db schema! See what you get when this hook is run (attached pict).

drikc’s picture

Status: Needs work » Fixed

Finally I have it done:

/**
 * Extend mail field length from 64 to 255 chars.
 */
function anonymous_posting_field_update_7100() {
  
  // Read field schema definition
  $field = field_info_field(ANONYMOUS_POSTING_FIELD_NAME);
  // Apply field schema definition
  field_update_field($field);
  
  return t('Mail field length successfully change to 255.');
}
drikc’s picture

Status: Fixed » Needs work

Mhh steel need work as it doesn't update the schema when the table contain data!

yashadev’s picture

Alright, I'll take a look at it again in a bit

yashadev’s picture

StatusFileSize
new909 bytes

Omg.. finally got it.

The following patch changes the varchar length in the database from 64 to 255.
It also adds a new line at the end of the file.

Note: Do not include the last "?>" part of the PHP code and leave a trailing blank line at the end of the file. This is the Drupal standard.

From How to Make a Simple Module with a Form and Menu Link

yashadev’s picture

Status: Needs work » Needs review
yashadev’s picture

Thanks for the commit. Question - the patch committed inserts the following:

function anonymous_posting_field_update_7103() {
  
  $field_info = field_info_field(ANONYMOUS_POSTING_FIELD_NAME);
  
  // Change mail column field length for current table
  $table = key($field_info['storage']['details']['sql'][FIELD_LOAD_CURRENT]);
  $mail_column_name = $field_info['storage']['details']['sql'][FIELD_LOAD_CURRENT][$table]['mail'];
  db_change_field($table, $mail_column_name, $mail_column_name, array('type' => 'varchar', 'length' => 255));
  
  // Change mail column field length for revision table
  $table = key($field_info['storage']['details']['sql'][FIELD_LOAD_REVISION]);
  $mail_column_name = $field_info['storage']['details']['sql'][FIELD_LOAD_REVISION][$table]['mail'];
  db_change_field($table, $mail_column_name, $mail_column_name, array('type' => 'varchar', 'length' => 255));
  
  return t('Mail field length successfully changed to 255.');
}

Is there a reason it updates the data table twice? Just curious

drikc’s picture

Status: Needs review » Fixed

I've modified some bits in you patch (revision table need to be updated also): http://drupalcode.org/project/anonymous_posting.git/commitdiff/d35971e?h...

yashadev’s picture

Ohh okay makes sense. Thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.