XF 2.2 Increasing the 150 character thread title limit

MaximilianKohler

Active member
For xf 2 you have to look at file

/src/XF/Entity/Node.php

find row

PHP:
        $structure->columns = [
            'node_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => true],
            'title' => ['type' => self::STR, 'maxLength' => 50,
                'required' => 'please_enter_valid_title'
            ],

and change to

PHP:
        $structure->columns = [
            'node_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => true],
            'title' => ['type' => self::STR, 'maxLength' => 100,
                'required' => 'please_enter_valid_title'
            ],
After changing that file is there something we have to do to get the changes to take effect?
Neither ngxrestart, fpmrestart, nor rebooting the server loaded the changes.
 
Last edited:
You'd still need to change the schema with the query in the original instructions, if you haven't already. Otherwise you shouldn't have to restart anything (unless you've configured OPCache not to check for file changes, in which case restarting PHP should suffice).

Note that changing the schema or core files is not officially supported and any updates will overwrite the file changes, so they would need to be reapplied.
 
You'd still need to change the schema with the query in the original instructions, if you haven't already. Otherwise you shouldn't have to restart anything (unless you've configured OPCache not to check for file changes, in which case restarting PHP should suffice).

Note that changing the schema or core files is not officially supported and any updates will overwrite the file changes, so they would need to be reapplied.
I'm not sure what you mean by "change the schema with the query in the original instructions". These instructions right? https://xenforo.com/community/threads/increase-the-50-character-forum-title-limit.13160/post-1309965
So instead of editing the file (with filezilla) I need to do something else? What?
 
No, these instructions: https://xenforo.com/community/threads/increase-the-50-character-forum-title-limit.13160/post-1128114

The post you linked has updated instructions for which file would need changing for XF2, as the original was for XF1.
So the only difference is that I need to run ALTER TABLE `xf_node` MODIFY title varchar(300), MODIFY node_name varchar(100); before editing the /src/XF/Entity/Node.php file?

I ran that in /home/nginx/domains/forum.mysite.com/public and got -bash: syntax error near unexpected token `('.

Will these changes revert after a Xenforo update? I saw a warning in another title-length-extension addon that if you uninstall their addon all titles over 150 char will be truncated and it's irreversible. Which would be a huge problem for me.

I'm coming to Xenforo from reddit and I'm trying to replicate the reddit titles (design & length). What would be the best way for me to do that? I haven't found any addons on this site https://xenforo.com/community/resources/categories/xenforo-2.42/ that do it.

I found some external sites that I'll have to look through:
customizexf https://www.customizexf.com/resources/
xf2 addons https://www.xf2addons.com/
Custom work https://pixelexit.com/

I found this addon https://xenforo.com/community/resources/cxf-customize-row-below-thread-title.6984/ that customizes the title layout to the way I want it (< with add-on and option to move the last poster to the row below thread title >), but I still need to increase the character limit to 300.
 
Last edited:
I ran that in /home/nginx/domains/forum.mysite.com/public and got -bash: syntax error near unexpected token `('.
It's an SQL query, not a terminal command. You'd need to run it via a tool like phpMyAdmin or the MySQL CLI.

Will these changes revert after a Xenforo update? I saw a warning in another title-length-extension addon that if you uninstall their addon all titles over 150 char will be truncated and it's irreversible. Which would be a huge problem for me.
Yes, per my original message the changes to the files would be overwritten each update and it would be necessary to reapply them. The titles themselves wouldn't be truncated by an update unless the core database schema changed, which is less likely. Also do note that the original thread and those modifications pertain to node titles and not thread titles.
 
It's an SQL query, not a terminal command. You'd need to run it via a tool like phpMyAdmin or the MySQL CLI.
Ah. I haven't installed phpMyAdmin because I read conflicting info on making it secure: https://community.centminmod.com/th...acme-sh-for-phpmyadmin-tool.21901/#post-96611

I did a search for MySQL CLI and it looks like it's already installed:
Code:
mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 754
Server version: 10.3.39-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> Ctrl-C -- exit!
Aborted

So I would just type:
Makefile:
mysql
ALTER TABLE `xf_node` MODIFY title varchar(300), MODIFY node_name varchar(100);
and then edit the /src/XF/Entity/Node.php file?

Regarding
Also do note that the original thread and those modifications pertain to node titles and not thread titles.
Ah, ok. I changed the title of this thread.
Can this same process be used to change the thread title limit to 300 characters? Something like:
Makefile:
mysql
ALTER TABLE `xf_node` MODIFY title varchar(100), MODIFY node_name varchar(100);
ALTER TABLE `xf_thread` MODIFY title varchar(300), MODIFY node_name varchar(100);
And then it would also require different edits to the /src/XF/Entity/Node.php file?
What do "title varchar" and "node_name varchar" each do?
Oh I see there's an /src/XF/Entity/Thread.php file too. What would I edit in there?

Yes, per my original message the changes to the files would be overwritten each update and it would be necessary to reapply them. The titles themselves wouldn't be truncated by an update unless the core database schema changed, which is less likely.
Ah ok, that's not a big deal for me. I'll run a manual backup of the database before applying updates.
 
Code:
mysql
use database_name;
ALTER TABLE `xf_node` MODIFY title varchar(50), MODIFY node_name varchar(50);
ALTER TABLE `xf_thread` MODIFY title varchar(150);

/src/XF/Entity/Node.php
Code:
        $structure->columns = [
            'node_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => true],
            'title' => ['type' => self::STR, 'maxLength' => 100,
                'required' => 'please_enter_valid_title', 'api' => true
            ],
            'node_name' => ['type' => self::STR, 'maxLength' => 100, 'nullable' => true, 'default' => null,
                'unique' => 'node_names_must_be_unique',
                'match' => 'alphanumeric_hyphen',
                'api' => true
            ],
/src/XF/Entity/Thread.php
Code:
        $structure->columns = [
            'thread_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => true],
            'node_id' => ['type' => self::UINT, 'required' => true, 'api' => true],
            'title' => ['type' => self::STR, 'maxLength' => 150,
                'required' => 'please_enter_valid_title',
                'censor' => true,
                'api' => true
            ],

Changes:
Code:
mysql
use database_name;
ALTER TABLE `xf_node` MODIFY title varchar(100), MODIFY node_name varchar(100);
ALTER TABLE `xf_thread` MODIFY title varchar(300);

/src/XF/Entity/Node.php
Code:
        $structure->columns = [
            'node_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => true],
            'title' => ['type' => self::STR, 'maxLength' => 100,
                'required' => 'please_enter_valid_title', 'api' => true
            ],
            'node_name' => ['type' => self::STR, 'maxLength' => 100, 'nullable' => true, 'default' => null,
                'unique' => 'node_names_must_be_unique',
                'match' => 'alphanumeric_hyphen',
                'api' => true
            ],

/src/XF/Entity/Thread.php
Code:
        $structure->columns = [
            'thread_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => true],
            'node_id' => ['type' => self::UINT, 'required' => true, 'api' => true],
            'title' => ['type' => self::STR, 'maxLength' => 300,
                'required' => 'please_enter_valid_title',
                'censor' => true,
                'api' => true
            ],

My results:

Code:
ALTER TABLE `xf_node` MODIFY title varchar(100), MODIFY node_name varchar(100);
Query OK, 13 rows affected (0.019 sec)
Records: 13  Duplicates: 0  Warnings: 0

ALTER TABLE `xf_thread` MODIFY title varchar(300);
Query OK, 0 rows affected (0.008 sec)
Records: 0  Duplicates: 0  Warnings: 0

  • Node names can now be extended.
  • I can type in a 300 character title (previously you couldn't keep typing after 150), but when I try to submit it I get:
Oops! We ran into some problems.
Please enter a value using 150 characters or fewer.


I looked up how to list the tables with MariaDB and ran SHOW TABLES; which did list xf_thread as a valid field:
Code:
 xf_thread                            |
| xf_thread_field                      |
| xf_thread_field_value                |
| xf_thread_prefix                     |
| xf_thread_prefix_group               |
| xf_thread_prompt                     |
| xf_thread_prompt_group               |
| xf_thread_question                   |
| xf_thread_read                       |
| xf_thread_redirect                   |
| xf_thread_reply_ban                  |
| xf_thread_type                       |
| xf_thread_user_post                  |
| xf_thread_view                       |
| xf_thread_watch

I checked the other thread*.php files to see if there was something else I need to edit, but didn't find anything obvious. I searched thread.php for "150" to see if there are other instances but there are not.

I looked up how to show table contents and ran SHOW COLUMNS FROM mytable; which listed:
Code:
+---------------------------+---------------------------------------+------+-----+---------+----------------+
| Field                     | Type                                  | Null | Key | Default | Extra          |
+---------------------------+---------------------------------------+------+-----+---------+----------------+
| thread_id                 | int(10) unsigned                      | NO   | PRI | NULL    | auto_increment |
| node_id                   | int(10) unsigned                      | NO   | MUL | NULL    |                |
| title                     | varchar(300)                          | YES  |     | NULL    |                |
| reply_count               | int(10) unsigned                      | NO   |     | 0       |                |
| view_count                | int(10) unsigned                      | NO   |     | 0       |                |
| user_id                   | int(10) unsigned                      | NO   | MUL | NULL    |                |
| username                  | varchar(50)                           | NO   |     | NULL    |                |
| post_date                 | int(10) unsigned                      | NO   | MUL | NULL    |                |
| sticky                    | tinyint(3) unsigned                   | NO   |     | 0       |                |
| discussion_state          | enum('visible','moderated','deleted') | NO   |     | visible |                |
| discussion_open           | tinyint(3) unsigned                   | NO   |     | 1       |                |
| discussion_type           | varchar(50)                           | NO   |     |         |                |
| type_data                 | mediumblob                            | NO   |     | NULL    |                |
| first_post_id             | int(10) unsigned                      | NO   |     | NULL    |                |
| first_post_reaction_score | int(11)                               | NO   |     | 0       |                |
| first_post_reactions      | blob                                  | YES  |     | NULL    |                |
| last_post_date            | int(10) unsigned                      | NO   | MUL | NULL    |                |
| last_post_id              | int(10) unsigned                      | NO   |     | NULL    |                |
| last_post_user_id         | int(10) unsigned                      | NO   | MUL | NULL    |                |
| last_post_username        | varchar(50)                           | NO   |     | NULL    |                |
| prefix_id                 | int(10) unsigned                      | NO   |     | 0       |                |
| tags                      | mediumblob                            | NO   |     | NULL    |                |
| custom_fields             | mediumblob                            | NO   |     | NULL    |                |
| vote_score                | int(11)                               | NO   |     | NULL    |                |
| vote_count                | int(10) unsigned                      | NO   |     | 0       |                |
+---------------------------+---------------------------------------+------+-----+---------+----------------+
25 rows in set (0.001 sec)

I compared it to xf_node and don't see anything that stands out:
Code:
SHOW COLUMNS FROM xf_node;
+-------------------------+---------------------+------+-----+---------+----------------+
| Field                   | Type                | Null | Key | Default | Extra          |
+-------------------------+---------------------+------+-----+---------+----------------+
| node_id                 | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
| title                   | varchar(100)        | YES  |     | NULL    |                |
| description             | text                | NO   |     | NULL    |                |
| node_name               | varchar(100)        | YES  | MUL | NULL    |                |
| node_type_id            | varbinary(25)       | NO   |     | NULL    |                |
| parent_node_id          | int(10) unsigned    | NO   | MUL | 0       |                |
| display_order           | int(10) unsigned    | NO   | MUL | 1       |                |
| display_in_list         | tinyint(3) unsigned | NO   | MUL | 1       |                |
| lft                     | int(10) unsigned    | NO   | MUL | 0       |                |
| rgt                     | int(10) unsigned    | NO   |     | 0       |                |
| depth                   | int(10) unsigned    | NO   |     | 0       |                |
| style_id                | int(10) unsigned    | NO   |     | 0       |                |
| effective_style_id      | int(10) unsigned    | NO   |     | 0       |                |
| breadcrumb_data         | blob                | YES  |     | NULL    |                |
| navigation_id           | varbinary(50)       | NO   |     |         |                |
| effective_navigation_id | varbinary(50)       | NO   |     |         |                |
+-------------------------+---------------------+------+-----+---------+----------------+
16 rows in set (0.001 sec)

I created a backup of mysql:
Code:
cd /home/
mysqldump --default-character-set=utf8mb4 myforumdb | gzip > db$(date +%F).sql.gz
And searched it for Please enter a value using 150 characters and got 0 results. So it seems like there's something else in the Xenforo config files that needs to be edited.
 
Last edited:
Thank you Jeremy!

I couldn't find last_thread_title in /src/XF/Entity/Thread.php or SHOW TABLES; or SHOW COLUMNS FROM xf_thread;, so I searched "xenforo last_thread_title" and found this thread, which mentioned it in the "Forum class". So I checked /src/XF/Entity/Forum.php and found it on line 629:
Code:
'last_thread_title'           => ['type' => self::STR, 'maxLength' => 150, 'default' => ''],

I changed it to 300, and then ran show columns from xf_forum;:
Code:
show columns from xf_forum;
+-----------------------------+---------------------------------+------+-----+----------------+-------+
| Field                       | Type                            | Null | Key | Default        | Extra |
+-----------------------------+---------------------------------+------+-----+----------------+-------+
| node_id                     | int(10) unsigned                | NO   | PRI | NULL           |       |
| discussion_count            | int(10) unsigned                | NO   |     | 0              |       |
| message_count               | int(10) unsigned                | NO   |     | 0              |       |
| last_post_id                | int(10) unsigned                | NO   |     | 0              |       |
| last_post_date              | int(10) unsigned                | NO   |     | 0              |       |
| last_post_user_id           | int(10) unsigned                | NO   |     | 0              |       |
| last_post_username          | varchar(50)                     | NO   |     |                |       |
| last_thread_id              | int(10) unsigned                | NO   |     | 0              |       |
| last_thread_title           | varchar(150)                    | NO   |     |                |       |
| last_thread_prefix_id       | int(10) unsigned                | NO   |     | 0              |       |
| forum_type_id               | varbinary(50)                   | NO   |     | discussion     |       |
| type_config                 | mediumblob                      | NO   |     | NULL           |       |
| moderate_threads            | tinyint(3) unsigned             | NO   |     | 0              |       |
| moderate_replies            | tinyint(3) unsigned             | NO   |     | 0              |       |
| allow_posting               | tinyint(3) unsigned             | NO   |     | 1              |       |
| count_messages              | tinyint(3) unsigned             | NO   |     | 1              |       |
| find_new                    | tinyint(3) unsigned             | NO   |     | 1              |       |
| allow_index                 | enum('allow','deny','criteria') | NO   |     | allow          |       |
| index_criteria              | blob                            | NO   |     | NULL           |       |
| field_cache                 | mediumblob                      | NO   |     | NULL           |       |
| prefix_cache                | mediumblob                      | NO   |     | NULL           |       |
| prompt_cache                | mediumblob                      | NO   |     | NULL           |       |
| default_prefix_id           | int(10) unsigned                | NO   |     | 0              |       |
| default_sort_order          | varchar(25)                     | NO   |     | last_post_date |       |
| default_sort_direction      | varchar(5)                      | NO   |     | desc           |       |
| list_date_limit_days        | smallint(5) unsigned            | NO   |     | 0              |       |
| require_prefix              | tinyint(3) unsigned             | NO   |     | 0              |       |
| allowed_watch_notifications | varchar(10)                     | NO   |     | all            |       |
| min_tags                    | smallint(5) unsigned            | NO   |     | 0              |       |
+-----------------------------+---------------------------------+------+-----+----------------+-------+
29 rows in set (0.002 sec)

Then
Code:
ALTER TABLE `xf_forum` MODIFY last_thread_title varchar(300);
And got:
Code:
ALTER TABLE `xf_forum` MODIFY last_thread_title varchar(300);
Query OK, 0 rows affected (0.008 sec)
Records: 0  Duplicates: 0  Warnings: 0

It worked!! Thank you very much!

Now I just have to figure out what to do about my new URLs:
https://forum.mysite.com/threads/wow-im-soo-happy-i-was-able-to-find-a-fix-to-make-these-titles-300-characters-now-i-can-put-the-full-title-of-the-study-and-also-include-a-quote-with-the-relevant-highlight-so-that-people-can-view-the-important-points-of-the-linked-article-or-study-when-looking-at-the-title-july-2023-review.11/
:LOL:
 
Just documenting changes & steps after the latest update.

I updated from 2.13 to 2.15. Usually I get a warning about 4 files being changed:
src/XF/BbCode/Renderer/Html.php Unexpected contents
src/XF/Entity/Forum.php Unexpected contents
src/XF/Entity/Node.php Unexpected contents
src/XF/Entity/Thread.php Unexpected contents
After the update it's only 3:
src/XF/BbCode/Renderer/Html.php
src/XF/Entity/Forum.php
src/XF/Entity/Node.php

Nothing on the forum seems changed, but new titles are limited to 150 char.

Code:
mysql
show databases;
use dbname;
SHOW COLUMNS FROM xf_node;
SHOW COLUMNS FROM xf_thread;
SHOW COLUMNS FROM xf_forum;

They all showed the expected customizations. So I checked the files that also need to be changed.
/src/XF/Entity/Node.php
/src/XF/Entity/Thread.php
/src/XF/Entity/Forum.php

Node was fine (100).
Thread maxLength was back to 150. Set it to 300.
Forum last_thread_title maxLength was still 300.

Everything back to normal. Reran the file check /admin.php?tools/file-check/ and back to 4 changed files.
 
Top Bottom