At the moment, node titles are limited to 128 characters long. This should be extended to at least 255 (if the database field stays as varchar) because

  1. 128 characters is too short.
  2. I have real examples of titles that are longer than 128 characters and are getting cut off.
CommentFileSizeAuthor
#11 node_title_length.patch2.32 KBhickory

Comments

Paul Natsuo Kishimoto’s picture

Version: 5.x-dev » 6.x-dev
Priority: Critical » Normal

Unless this is breaking Drupal, I would argue it isn't critical. It seems to only be forcing you to write shorter titles... however, I support the idea.

hickory’s picture

This seems to fix things for now:

ALTER TABLE `node_revisions` DROP INDEX `title` ,
ADD FULLTEXT `title` ( `title` ( 10 ) , `body`);

ALTER TABLE `node_revisions` CHANGE `title` `title` TEXT;

ALTER TABLE `node` DROP INDEX `node_title_type`,
ADD INDEX `node_title_type` ( `title` ( 10 ) , `type` ( 4 ) );

ALTER TABLE `node` CHANGE `title` `title` TEXT ;

I think this is pretty important, and it would be good to see it in Drupal 5.

Zen’s picture

Status: Active » Needs work

128:
This is a very long title. This is a very long title. This is a very long title. This is a very long title. This is a very long

255:
This is a very long title. This is a very long title. This is a very long title. This is a very long title. This is a very long. This is a very long title. This is a very long title. This is a very long title. This is a very long title. This is a very l

Users who want longer titles can just create a custom title field. This should, IMO, be more than sufficient for mainstream users esp. considering that D6 is MySQL 4+.

@hickory: Please submit your changes in patch form. It will also need to include an update function.

Thanks,
-K

hickory’s picture

What's the disadvantage of making the field TEXT, rather than limiting to a 255-char VARCHAR?

Paul Natsuo Kishimoto’s picture

@zen: I don't understand why Drupal 6 requiring MySQL 4 or greater affects this issue. If anything, TEXT is more portable (considering support for other DBMS is always a good thing). Node titles should just work; a user would be substantially annoyed at having to create custom fields simply to enter a 129-character title. 128, 256 and similar numbers are entirely arbitrary. While they may seem comfortable sizes for English titles, they may be annoyingly restrictive in other languages. Arbitrary-length strings with TEXT would remove this problem.

@hickory: as far as I know, there isn't. Roll that patch!

Zen’s picture

4.0+ provides Unicode support. It is my understanding that 255 characters will now be 255 characters in all languages.

As to why TEXT is bad, please google for CHAR vs. VARCHAR vs. TEXT comparisons, keeping in mind the current indices of the node table. By your reasoning, we shouldn't have VARCHAR at all in our databases, eh?

Thanks,
-K

killes@www.drop.org’s picture

Making titles TEXT could affect theintendedport to Oracle:

http://www.oracle.com/technology/pub/articles/pedros-drupal.html

hickory’s picture

What I understand from the Oracle article linked above is that it would use CLOB fields for long text as much as possible. The field types are presumably backend-specific anyway, so that shouldn't be a problem.

Speed is the main issue, I think. It would be good if someone could benchmark the difference.

dmitrig01’s picture

Status: Needs work » Active

no patch...

hickory’s picture

Where would a patch for this go now? node.install?

hickory’s picture

Status: Active » Needs review
StatusFileSize
new2.32 KB

Here's a patch for node.schema. I'm not sure if I've defined the 'node_title_type' index properly.

ChrisKennedy’s picture

Status: Needs review » Closed (duplicate)
hickory’s picture

Title: Node titles are too short » Make the database field for node titles TEXT
Status: Closed (duplicate) » Needs review

Reopening as the other patch only increased the title length to 255.

catch’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs review » Needs work

Needs to be re-rolled for scheme api, for drupal 7.

catch’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs work » Closed (won't fix)

Actually I'm going to mark this to won't fix. This could hit performance a lot on sorts since text (I think) requires temporary tables on sort.

CCK and automatic node titles provides a way to get the same functionality in contrib. If a title is longer than 256 characters then it's not really a title imo.

hickory’s picture

Status: Closed (won't fix) » Needs work

*Please* don't mark this as wontfix unless benchmarks have been run. There have been previous theoretical objections relating to speed, but no-one's actually shown that this is a real problem, so far. On the other hand, I have a site where a large percentage of the nodes have titles longer than 255 characters (scientific papers, mostly), so this *is* a real problem.

catch’s picture

Version: 6.x-dev » 7.x-dev

This thread deals with temporary tables to disk in taxonomy module: http://drupal.org/node/171685 - where converting a BLOB/TEXT column to varchar 255 was proposed for similar reasons. Leaving it as patch needs work anyway.

catch’s picture

Status: Needs work » Closed (won't fix)

255 characters is still plenty, you can't do indexed conditions or order by on text tables, which you need for node titles very often, so back to won't fix. EXPLAIN is better than benchmarks for this.

hickory’s picture

In that case, what should the recommended workaround be for sites with node titles longer than 255 characters? Create a separate field to hold the full title and store a truncated version in node.title?

catch’s picture

I think so yeah - worth looking at http://drupal.org/project/auto_nodetitle which lets you hide the title field completely and generate the contents using token.module