1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XFCP class being redeclared?

Discussion in 'XenForo Development Discussions' started by Liam W, May 19, 2013.

  1. Liam W

    Liam W Well-Known Member

    I am getting the error message:

    since I logged out.

    I don't know what's causing this - the last time I got this, I had two files with the same class name for two different addons, but I don't this time.

    Any ideas?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    It definitely is this:
    That's the standard error PHP throws when the same class name is redeclared.

    You will need to disable add-ons and enable each one to work out which one is causing it.
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  4. Liam W

    Liam W Well-Known Member

  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You are only extending the register controller? Nothing else?
     
  6. Liam W

    Liam W Well-Known Member

    Nope, nothing else. And it's definitely the only file.

    And it has stumped me :(
     
  7. Chris D

    Chris D XenForo Developer Staff Member

    What does your Event Listener code look like?
     
    Jake Bunce likes this.
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Can you post all relevant addon code? The listener and the actual extended class?

    What action is triggering this error?

    edit - ninjaaaaaa
     
    Chris D likes this.
  9. Liam W

    Liam W Well-Known Member


    It's just a redeclared php error.

    Also, I belive this is what you want:

    PHP:
    public static function listener($class, array &$extend)
    {
        if (
    $class 'XenForo_ControllerPublic_Register')
        {
            
    $extend[] = 'UserReferrals_ControllerPublic_Register';
        }
    }
    PHP:
    <?php
     
    class UserReferrals_ControllerPublic_Register extends XFCP_UserReferrals_ControllerPublic_Register
    {
     
        public function 
    actionRegister()
        {
     
            
    parent::actionRegister();
     
            
    $session $cookies XenForo_Application::getSession();
     
            if(
    $referringuser $session->get('referral_id'))
            {
     
                
    $dw XenForo_DataWriter::create('UserReferalls_DataWriter_DataWriter');
                
    $dw->set('userid'XenForo_Visitor::getUserId());
                
    $dw->set('referred_by'$referringuser);
                
    $dw->save();
            }
     
        }
     
        public function 
    _getModel()
        {
            return 
    $this->getModelFromCache('UserReferrals_Model_Model');
        }
     
    }
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    This is wrong:

    PHP:
    public static function listener($class, array &$extend)
    {
        if (
    $class 'XenForo_ControllerPublic_Register')
        {
            
    $extend[] = 'UserReferrals_ControllerPublic_Register';
        }
    }
    Should be $class == 'XenForo_ControllerPublic_Register'
     
    HWS and Jake Bunce like this.
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    PHP:
    public static function listener($class, array &$extend)
    {
        if (
    $class 'XenForo_ControllerPublic_Register')
        {
            
    $extend[] = 'UserReferrals_ControllerPublic_Register';
        }
    }
    if ($class = 'XenForo_ControllerPublic_Register') ......

    You need a double equals for comparison.
     
    Chris D likes this.
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  13. Chris D

    Chris D XenForo Developer Staff Member

    Sorry Jake :(
     
  14. TheBigK

    TheBigK Well-Known Member

Share This Page