Renaming custom BBCodes in phpBB 3.2

Get help developing custom BBCodes or request one.
Post Reply
User avatar
Electrix
Registered User
Posts: 41
Joined: Mon Apr 13, 2015 10:21 am
Location: Czech Republic

Renaming custom BBCodes in phpBB 3.2

Post by Electrix » Tue Mar 13, 2018 7:57 pm

Hello,

recently I have run into some BBCode issues with my board, so I decided I'll try to simplify them as much as possible to avoid future conflits. Let me give you one very simple example:

Before:

Code: Select all

[center]centered text[/center]
[left]text on left side[/left]
[right]text on right side[/right]
After:

Code: Select all

[align=center]centered text[/align]
[align=left]text on left side[/align]
[align=right]text on right side[/align]
I already know, how to safely make this BBCode (through special keyword CHOICE). The problem is I need to replace tag name in all existing posts on my board (about 1,5 milion). Sometimes not only BBCode, but also its HTML replacement will slightly change. As far as I know, phpBB doesn't provide any renaming mechanism for that. There is a phpbbcli.php interface for reparsing BBCodes, but I think this is not a situation, where I can use it (or is it?).

I've quickly looked up the "posts" table in MySQL. It seems, that simple saved post with [center] tag (field post_text) looks like this:

Code: Select all

<r><CENTER><s>[center]</s>Example centered text<e>[/center]</e></CENTER></r>
Correct me if I'm wrong assuming both BBCode and its HTML replacement are saved in post side by side. That'd mean the best option will be some PHP script, that will search and replace both BBCode and HTML using regular expressions. But what about fields post_checksum, bbcode_bitfield and bbcode_uid - do they also need to be altered in the process? And more importantly, is there for example some syntatic feature I need to be careful about (in more advanced BBCodes)? Is it possible to somehow reuse the phpbb/textreparser classes for this purpose (and avoid reinventing the wheel)?

I already tried searching on this board and found some similar questions. But all of them were quite old and from what i saw the syntax has changed a lot since then.

So, my question is: Where do I start? I'm sure somebody out there faced similar problem in the past. I'll appreciate any help or advice.
„Only a life lived for others is a life worthwhile.“[A. Einstein]

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 48882
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Renaming custom BBCodes in phpBB 3.2

Post by stevemaury » Wed Mar 14, 2018 1:48 pm

How about using SQL to replace all instances of [center] with [align=center], etc., and then using CLI to reparse?

Like:

Code: Select all

update phpbb_posts set post_text = replace(post_text, '[center]', '[align=center]')
And so on for the other tags.

I would try this on a test database (copy) first.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. PM or email me.

All unsolicited PMs will be ignored.

Post Reply

Return to “Custom BBCode Development and Requests”

Who is online

Users browsing this forum: No registered users and 4 guests