I'm trying to bootstrap Drupal (I'm making a rather simple bridge that automaticly logs a user into Drupal when they sign into PhpBB). I have the following code placed in the succes scenario of a succesful PhpBB login:

// DrupalBridge
function drupalbridge_login($username, $password)
    define('DRUPAL_ROOT', getcwd() . "/..");

    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

    global $user;

    $account = user_authenticate($username, $password);

    // Woah, it seems like we don't know this user, let's create him!
    if (!$account) {
        $userinfo = array(
            'name' => $name,
            'pass' => $pass,
            'init' => $name,
            'status' => 1,
            'access' => REQUEST_TIME,
        $account = user_save(drupal_anonymous_user(), $userinfo);
        $loadme = user_authenticate($name, $pass);

    $user = user_load($loadme, TRUE);

This function works perfectly on its own. The problem is that this is in a giant file in the PhpBB system, where the user_delete() function is already defined, causing a Fatal error: Cannot redeclare user_delete(). The user_delete() function is deep inside the PhpBB core so I can't just rename that function either.

How can I solve this problem while still maintaining the functionality?

==Update== I managed to fix the problem with the overlapping functions by changing the user_delete to phpbb_user_delete, as phpbb will also work with the phpbb_ prefix but I've run in to another problem now: Drupal bootstrap external login from subfolder isn't working

Thanks in advance, Silox

closed as off topic by Letharion, Triskelion, AjitS, niksmac, Mołot Jun 25 '13 at 6:47

Questions on Drupal Answers are expected to relate to Drupal within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I have to say I think this is off-topic. This is a PHP namespacing issue, and doesn't relate to Drupal. – Letharion Jun 24 '13 at 18:10
  • When I wanted to boostrap PhpBB into Drupal, I could prefix the PhpBB methods with phpbb_. So if it could be fixed in the same way, this would be on-topic. – Silox Jun 24 '13 at 18:12

Instead of mashing the Drupal bootstrap into PHPBB, you could authenticate the user via an external API request to Drupal,

For example, using the Services module, with session authentication.

curl --data "username=test&password=pass" https://www.example.com/api/rest/user/login
  • Thank you for your anwser. I installed the Services module and got the curl working but I was wondering: Is the login persistent? If I execute the curl request in PHP, and I navigate to the Drupal section of the site, will the user be still logged in? – Silox Jun 25 '13 at 7:58
  • If you pass the session id information returned with the login request in subsequent requests, the user will be authenticated as that user. – David Thomas Jun 25 '13 at 8:04
  • Then I'm afraid this isn't the proper solution for what I want to do. I'm using Drupal in combination with PhpBB. When a user logs into PhpBB, I want him to be logged in to Drupal too. I can't know when the user will go back to the Drupal section of the site so I can't keep on passing the sid around on PhpBB part of the site, never knowing when the user might go to the Drupal section. – Silox Jun 25 '13 at 8:08

You could perhaps work around this by renaming the functions inside your block using http://php.net/manual/en/function.rename-function.php

Just be careful, you're dealing with PECL stuff ;)

  • One would presumably still have to patch user_delete to look at the incoming args and have it determine which function to actually call, which is less than pretty. – Letharion Jun 24 '13 at 18:53

The only on-topic solution I can think of is to move to Drupal 8, which uses name spaces.

You could of course also do something like sed s/user_delete/drupal_user_delete/g, though that's going to be very complicated, given false positives and such.

Not the answer you're looking for? Browse other questions tagged or ask your own question.