• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Variable renaming

Status
Not open for further replies.

Kazaam

Chevereto Member
Hello

I'm currently preparing PHPBB integration in Chevereto (at the moment, authentication)

As I see, Chevereto and PHPBB use same naming for some variables
$user, $db, $config, $template

I change names for my tests just by replacing first letter by an upper case.

I think, it may be easiest to rename variables in Chevereto than modifying PHPBB :)


regards
 
I'm pretty sure that a lot of scripts use variables like $user $db, $template, etc. Thing is that in Chevereto to make integrations you should rely on the API and use that to make things communicate. If the bundled API (api.php) is not enough for you, you should extend the API on your own.

And in any script you shouldn't include or connect direct internal methods to make integrations. In that case you should fork instead of integrate.
 
I'm very far to be a PHP master, problem is PHPBB needs to declare some variables in "Global".
That declaration is in conflict with chevereto

I understand usage of API, in case of need chevereto functions in something else, but in this case it's chevereto that require info to another system according to this documentation :
https://www.phpbb.com/kb/article/phpbb3-sessions-integration/

I'm not sure that I can create something like an API file to access PHPBB without overwriting chevereto global variables
 
The APIs have been made to allow programs to communicate without the old problems like this one. Chevereto comes with an end-point (api.php) that you can trigger to perform upload operations from almost anything out there. If you want that Chevereto hooks things that belongs to phpbb (like add user sessions and things like that) you will need more work than just call the API.

I believe that the best for you is create a bridge or connector. A bridge is a way to have something in the middle that makes the communication between the systems. In Chevereto.com I have a connector to xenforo and when the forum was punbb I also had a custom punbb connector. The key is load it at an early line in the Chevereto code execution. When you load phpbb it will declarate its variables and classes. You only need to copy them to new variables, like $phpbb_user = $user; That will create a copy of $user and you can access using $phpbb_user. Later in the PHP execution Chevereto will overwrite this original phpbb $user with its own $user and everything will work. Since you changed the default phpbb $user, you will need to call it always as $phpbb_user from now on (Chevereto code).

Notice that if phpbb and chevereto share functions like I don't know... get_config() or things like that, Chevereto will also override those. Take note that the best practice is use this connectors to get and set data. Not to extend functions of phpbb inside Chevereto and you shouldn't rely in the phpbb functions when doing this. In that case you can easily create functions like is_phpbb_user() in the very same connector and call that function inside Chevereto, maybe clone the phpbb needed functions or objects. Try to don't call direct phpbb functions.
 
Thanks for these explanations :)
I see the problem for same name usage, I cheat for some parts but it's not actually perfect, PHPBB session brake Chevereto session and it's not possible to upload files anymore....
I think my problem comes from wrong place for PHPBB call. As I see chevereto.php is the common file for all others files but if you use private mode, login page come previously.

I hope this is my last question before release something usable by other : What is the first and common file for all cases ?

thanks
 
From V3 we use namespaces, no more conflict issues for now.
 
Status
Not open for further replies.
Back
Top