Is it possible to change topic id number?

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
Zinnn
Registered User
Posts: 88
Joined: Sun Apr 21, 2019 8:14 am

Is it possible to change topic id number?

Post by Zinnn »

I.e. I have this thread:
viewtopic.php?f=2&t=2458

Theoretically, is it possible to change its number from 2458 to 2300 for example (providing #2300 is not existing, because it was deleted). If yes, how can I do it? Phpmyadmin? Is there a guide somewhere? Tried searching but failed :(

Thanks
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Is it possible to change topic id number?

Post by david63 »

Why would you want to do it?

Yes it could be done but topic ids are in several tables so you would have to change the id everywhere otherwise you would break your board.
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53398
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Is it possible to change topic id number?

Post by Brf »

david63 wrote: Tue Sep 21, 2021 5:46 pm several tables
topics, posts, forums, multiple polls tables, topic-watch, topic-track, bookmark, drafts, and a couple more.

I do not know what the point of changing an arbitrary topic number would be.
Zinnn
Registered User
Posts: 88
Joined: Sun Apr 21, 2019 8:14 am

Re: Is it possible to change topic id number?

Post by Zinnn »

Brf wrote: Tue Sep 21, 2021 6:08 pm
david63 wrote: Tue Sep 21, 2021 5:46 pm several tables
topics, posts, forums, multiple polls tables, topic-watch, topic-track, bookmark, drafts, and a couple more.

I do not know what the point of changing an arbitrary topic number would be.
To fill in the gaps from deleted threads in the past. I've also split some old threads into separate ones, and wanted to assign them lower numbers.

So the hastle of changing multiple tables is the only issue here? Or can I break the forum by doing it? I'm talking here about newly generated threads, all with one post only.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Is it possible to change topic id number?

Post by david63 »

Zinnn wrote: Wed Sep 22, 2021 4:53 pm So the hastle of changing multiple tables is the only issue here? Or can I break the forum by doing it?
If you get it wrong then yes you could cause serious problems with your board - it is not something that I would attempt to do. Also renumbering topics randomly may cause some unexpected results if topics are sorted by their id.

Quite honestly I cannot see what the problem is as basically it is just an internal reference and I doubt for one minute that any of your members would even notice.
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
AlfredoRamos
Recognised Extension Developer
Posts: 1302
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo
Contact:

Re: Is it possible to change topic id number?

Post by AlfredoRamos »

Zinnn wrote: Wed Sep 22, 2021 4:53 pm So the hastle of changing multiple tables is the only issue here?
Well, that's enough trouble in my opinion, because if you intend to change the ID to more than 1 topic, you'll have to automatize the change, and make sure you don't leave your tables in a broken state.
Zinnn wrote: Wed Sep 22, 2021 4:53 pm I'm talking here about newly generated threads, all with one post only.
Newly generated topics won't use lower IDs to fill those sequence gaps, they will be +1 higher than the last ID on your tables, so they won't be affected nor do what you want.

If you change the sequence (the internal RDBMS one), you will surely break all your database.

No offense, but it seems that you don't know the implications of what you are doing (or want to do), and hence, unless you are very proficient in database management, you shouldn't try to do any database changes.
Some of my phpBB extensions:
:chart_with_upwards_trend: SEO Metadata | Image Markdown | :shield: hCaptcha
:trophy: Check out all my validated extensions :trophy:

:penguin: Arch Linux user | Linux Boards :penguin:
Zinnn
Registered User
Posts: 88
Joined: Sun Apr 21, 2019 8:14 am

Re: Is it possible to change topic id number?

Post by Zinnn »

AlfredoRamos wrote: Wed Sep 22, 2021 8:52 pm No offense, but it seems that you don't know the implications of what you are doing (or want to do), and hence, unless you are very proficient in database management, you shouldn't try to do any database changes.
No problem, thank you for explaining this, I won't touch a thing :)
User avatar
Sniper_E
Registered User
Posts: 1134
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Is it possible to change topic id number?

Post by Sniper_E »

What if he copied the topic to another forum, it would be the same topic with a different topic_id number.? Yea? No?
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 5871
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Is it possible to change topic id number?

Post by thecoalman »

Sniper_E wrote: Thu Sep 23, 2021 1:55 am What if he copied the topic to another forum, it would be the same topic with a different topic_id number.? Yea? No?
Yes it would have it's own ID but it would be incremented from last topic created. The OP wants to use lower numbers presumably from deleted topics.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
wualla
Registered User
Posts: 4
Joined: Sat Apr 16, 2022 12:14 pm

Re: Is it possible to change topic id number?

Post by wualla »

I got this thread looking for a way to change the topic identification number.

My problem is that I made a mistake in merging two topics and the final topic identification number was taken from the new topic and not from the old one. The real issue is that the old topic was quite large and the entire bulletin board is riddled with links to that topic which are currently broken.

Maybe modifying the topic identification number back to the original one is not the best solution but what other options would I have?
User avatar
battye
Extension Customisations
Extension Customisations
Posts: 11048
Joined: Wed Feb 11, 2004 11:02 am
Location: Australia
Contact:

Re: Is it possible to change topic id number?

Post by battye »

wualla wrote: Sat Apr 16, 2022 12:22 pm I got this thread looking for a way to change the topic identification number.

My problem is that I made a mistake in merging two topics and the final topic identification number was taken from the new topic and not from the old one. The real issue is that the old topic was quite large and the entire bulletin board is riddled with links to that topic which are currently broken.

Maybe modifying the topic identification number back to the original one is not the best solution but what other options would I have?
I've got a couple of left field ideas - could you create a word/swear filter that replaces the links? eg. a filter to change viewtopic.php?t=XXXXX with viewtopic.php?t=YYYYY so that all of the original links point to the new topic.

It could be worth trying that because it's an easy one to experiment with. Maybe it won't play nice with the url bbcode's though.

Another thing you could do, which is a bit of a quick and dirty fix but I see no reason why it wouldn't work if you're comfortable modifying PHP files, would be at the top of viewtopic.php just under https://github.com/phpbb/phpbb/blob/a12 ... ic.php#L31 $topic_id = $request->variable('t', 0);, add $topic_id = ($topic_id === XXXXXX) ? YYYYYY : $topic_id; // Replace XXXXXX with the original topic id, YYYYYY with the new topic id. That way whenever anyone tries to view the original topic, it will redirect them to the new topic.
Customisations Team Member

https://github.com/battye/php-array-parser - Give it a Star! :D
wualla
Registered User
Posts: 4
Joined: Sat Apr 16, 2022 12:14 pm

Re: Is it possible to change topic id number?

Post by wualla »

battye wrote: Sun Apr 17, 2022 7:29 amI've got a couple of left field ideas - could you create a word/swear filter that replaces the links? eg. a filter to change viewtopic.php?t=XXXXX with viewtopic.php?t=YYYYY so that all of the original links point to the new topic.

It could be worth trying that because it's an easy one to experiment with. Maybe it won't play nice with the url bbcode's though.

Another thing you could do, which is a bit of a quick and dirty fix but I see no reason why it wouldn't work if you're comfortable modifying PHP files, would be at the top of viewtopic.php just under https://github.com/phpbb/phpbb/blob/a12 ... ic.php#L31 $topic_id = $request->variable('t', 0);, add $topic_id = ($topic_id === XXXXXX) ? YYYYYY : $topic_id; // Replace XXXXXX with the original topic id, YYYYYY with the new topic id. That way whenever anyone tries to view the original topic, it will redirect them to the new topic.
These are excellent proposals but I would not implement them in the forum. If that were my goal I would find it easier and cleaner to do a search and replace in the database tables to modify the old topic number with the new one in all the related posts; but I won't do it because there are many links to the old topic number on other web sites and search engines.

I see there is no way to undo my failed operation of merging topics, nor any specific feature to change the topic identification number (even indirectly using e.g. moving messages to another topic) I conclude that ultimately the only effective solution is to modify the topic identification number in all the tables involved in the database. The first time can be painful because it requires to study the relational structure in which the topic identification number is involved in the whole database but done that eventually it should not be so complex to write a script to exchange one topic identification number for another.
Post Reply

Return to “[3.3.x] Support Forum”