PHPBB3-13802 - Offer a way for extensions to configure the text_formatter.parser service for a given user

Discuss requests for comments/changes posted in the Issue Tracker for the development of phpBB. Current releases are 3.2/Rhea and 3.3/Proteus.
Post Reply
User avatar
JoshyPHP
Registered User
Posts: 381
Joined: Fri Jul 08, 2011 9:43 pm

PHPBB3-13802 - Offer a way for extensions to configure the text_formatter.parser service for a given user

Post by JoshyPHP »

Some extensions such as ABBC3 want to toggle some features based on a post's author. In 3.1, this is done via generic events such as core.modify_bbcode_init by using the global $user object. In 3.2, this can be done via the core.text_formatter_s9e_parser_setup event.

I think that using the global $user object is incorrect. I'm not entirely sure though. It does interfere with reparsing posts, because the current user is not necessarily the author. Perhaps there should be an event that lets extensions toggle features according to a given user's permissions/preferences? Or is it correct for extensions to use the global user? I'm looking for feedback because I have not formed on that matter.

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: PHPBB3-13802 - Offer a way for extensions to configure the text_formatter.parser service for a given user

Post by MattF »

ABBC3 uses that event to block certain reserved bbcodes during post creation based on the group a user belongs to. Your event and this work perfectly in ABBC3. The $user object is the only way to know who the user currently is, but it's not needed from your event since it can just as easily be injected into the extension's classes where needed.
https://github.com/VSEphpbb/abbc3/blob/ ... #L219-L228

I wouldn't say your parser is the problem...the reparsing is the problem. I would think post reparsing should be done with full admin permissions. Doing it based on whoever the lucky user is that triggered a reparse cron task is going to be ugly, because phpBB already has other built in user perms for bbcodes (flash, img, url). It could even be triggered by a bot or guest, for example.

Heck it may be better just to make reparsing the posts a part of the database update to 3.2...just sayin'...

Or...maybe you could make a reparser class that extends the parser class, replacing the methods with the events, so extensions can't introduce user based permissions that might interfere with the reparsing.
Has an irascible disposition.

User avatar
rxu
Registered User
Posts: 164
Joined: Tue Apr 04, 2006 4:28 pm
Contact:

Re: PHPBB3-13802 - Offer a way for extensions to configure the text_formatter.parser service for a given user

Post by rxu »

If we want to grant extensions the possibility to toggle things depending on the user permissions, we'd need to add the $auth dependency to the parser/event.
In theory, some extensions would want to operate some user's data to decide what to do with BBcode while parsing the post. But, if the data from USERS_TABLE is needed, it can be retrieved using additional SQL query. I guess the $user object dependency would be needed if you want to operate the data generated during the session handling, like is_registered/is_bot etc.

EDIT: and actually VSE is right, having just $parser seems to be sufficient as extensions can use their own $user/$auth dependencies to decide what parser configuration to apply.
Image

Post Reply