Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2457

[3.3.x] Support Forum • Re: Fixing post_text BBCode via DB

$
0
0

Code:

|post_id  |topic_id|forum_id|poster_id|icon_id|poster_ip     |post_time    |post_reported|enable_bbcode|enable_smilies|enable_magic_url|enable_sig|post_username|post_subject                                       |post_text                                                                                                                                                                                                                                                                                                                                                     |post_checksum                   |post_attachment|bbcode_bitfield|bbcode_uid|post_postcount|post_edit_time|post_edit_reason|post_edit_user|post_edit_count|post_edit_locked|post_visibility|post_delete_time|post_delete_reason|post_delete_user|sfs_reported||---------|--------|--------|---------|-------|--------------|-------------|-------------|-------------|--------------|----------------|----------|-------------|---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|---------------|---------------|----------|--------------|--------------|----------------|--------------|---------------|----------------|---------------|----------------|------------------|----------------|------------||2,226,246|154,833 |27      |21,503   |0      |162.158.134.15|1,730,217,615|0            |1            |1             |1               |0         |             |Re: Game Freeze/Crash When join and spown in server|<t>[quote="Spaitro"]Thank you so much!<br/>¶<br/>¶Everything worked flawlessly once I installed the files in the game folder, and now it’s running perfectly. I’m incredibly grateful for all the support and solutions you provided—it made all the difference. Thanks again![/quote]<br/>¶<br/>¶Thank you for reporting back. All the best and have fun!</t>|bd91a34c457db70050cfafc316983daa|0              |               |10x504x2  |1             |0             |                |0             |0              |0               |1              |0               |                  |0               |0           |
Thank you very much for the replies. This is the full DB row, so enable_bbcode is clearly enabled for this :( . Would have been an easy win.

The parser was called with

Code:

bin/phpbbcli.php reparser:reparse post_text --ansi --range-min=2226245 --range-max=2226247
The hint regarding the <t> tag was a good idea, sadly we also have some posts with <r> that have equally broken quotes and behave exactly the same otherwise. They also get fixed when preview/saving them via frontend, but not via reparser CLI.

My biggest confusion is why the reparser CLI handles text differently than the frontend "Save/edit" post feature, given that the latter produces working results, whereas the CLI doesn't.


But you at least got me on the right track. Some "beautiful" regex SQL (MariaDB) fixes this singular issue. I'm sharing it because it might be helpful for others, too. Still, be careful, it's not overly smart, I just added a simple negative lookahead to prevent it from updating the same quotes it already targeted. Obviously you need to change it into an update statement as well, but always use SELECT first to check what you are doing. And it will only work properly for posts with a single quote in them.

Code:

SELECT post_id, post_text, REGEXP_REPLACE(post_text, '(?s)^<.>(.*)(?<!<s>)\\[quote=(.*?)\\](.*)\\[\\/quote\\].*<\\/.>$','<r>\\1<QUOTE author=\\2><s>\[quote=\\2\]</s>\\3<e>\[\/quote\]<\/e><\/QUOTE>\\4</r>') AS replaced FROM phpbb.bb_posts WHERE `enable_bbcode` = 1 AND `post_text` LIKE '%[q%' AND (post_id = 2226232 OR post_id = 2226246)

I guess I'll just have to experiment some more to see if I can safely catch all those broken posts without setting other stuff on fire.

Statistics: Posted by Senshi_x — Fri Nov 22, 2024 5:35 pm



Viewing all articles
Browse latest Browse all 2457

Trending Articles