Adding phpbb prefix to functions

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Adding phpbb prefix to functions

Post by Oleg »

A question arose in https://github.com/phpbb/phpbb3/pull/1144 whether we should add phpbb prefix to functions.

To be honest I rather thought we wanted this all along.

Therefore in that particular PR I added the prefix as the argument list was changed anyway.

User avatar
tumba25
Registered User
Posts: 14
Joined: Sun Feb 01, 2009 10:13 pm
Location: Kokkola, Finland.
Contact:

Re: Adding phpbb prefix to functions

Post by tumba25 »

Totally agree.
Image

Need a mod created/installed, other custom-coded solution or a server admin? https://tumba25.net


User avatar
DarkBeing
Registered User
Posts: 83
Joined: Sun Jul 19, 2009 2:32 pm
Location: Currently Estonia
Contact:

Re: Adding phpbb prefix to functions

Post by DarkBeing »

+1

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Adding phpbb prefix to functions

Post by MichaelC »

I'm sure there was an RFC for this a while back and it was agreed. https://github.com/imkingdavid/phpbb3/c ... ask/phpbb_ and https://github.com/unknownbliss/phpbb3/ ... ask/phpbb_
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Adding phpbb prefix to functions

Post by imkingdavid »

For a while there has been a (mabe unwritten, but enforced) rule that any and all new non-member functions (i.e. anything not within a class) should have a phpbb_ prefix. And of course all classes should be prefixed with phpbb_ for autoloading among other reaons. I'm not sure we need to go through all the trouble of renaming all existing functions as was linked to by Michael, however, as that would definitely break compatibility for all MODs that use any native phpBB function.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Adding phpbb prefix to functions

Post by MichaelC »

imkingdavid wrote:For a while there has been a (mabe unwritten, but enforced) rule that any and all new non-member functions (i.e. anything not within a class) should have a phpbb_ prefix. And of course all classes should be prefixed with phpbb_ for autoloading among other reaons. I'm not sure we need to go through all the trouble of renaming all existing functions as was linked to by Michael, however, as that would definitely break compatibility for all MODs that use any native phpBB function.
We were only renaming functions that were likely to be used by other softwares (very generic terms like add_user()) that phpBB integrated with but we also added wrappers to keep BC.

Although the wrappers were decapreated and therefore would likely be removed completely in future versions.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Adding phpbb prefix to functions

Post by EXreaction »

Unless there is a specific incident with naming collision with other popular software, I do not support renaming existing functions.

3.x is not supposed to cause serious issues for backwards compatibility, that is why 3.1 is 3.1 and not 4.0.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Adding phpbb prefix to functions

Post by MichaelC »

EXreaction wrote:Unless there is a specific incident with naming collision with other popular software, I do not support renaming existing functions.

3.x is not supposed to cause serious issues for backwards compatibility, that is why 3.1 is 3.1 and not 4.0.
Did you look at the commits I linked to/read my previous post? All the functions had wrappers so no BC was broken.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Adding phpbb prefix to functions

Post by EXreaction »

I do not see how renaming the function and then adding a wrapper in the same location is beneficial.

Wrapping functions in if (!function_exists()) also would make debugging significantly more difficult for board administrators. If there would be a conflict it would be very clear what the issue was; however if there was a conflict, but the wrapper was not created because it checks if (!function_exists()) and some old code calls the original function name, very strange or potentially damaging things can happen to the system because unexpected variables will be sent to an unknown function.

At the least, wrappers should be put in a separate file so they can be cleaned up in the future and managed by the board administrator if they must deal with a specific collision incident and should not be wrapped in if (!function_exists()).

Post Reply