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

Not a Bug resolveDynamicClass issue with namespace and $fakeNeeded

Discussion in 'Resolved Bug Reports' started by xfrocks, Sep 20, 2014.

  1. xfrocks

    xfrocks Well-Known Member

    I have found an issue with the way XenForo_Application::resolveDynamicClass deals with fake class. It will generate invalid code if the $class is in some namespace.

    PHP:
            if ($fakeNeeded)
            {
                if (!
    $extend)
                {
                    return 
    false;
                }

                eval(
    'class ' $class ' extends ' $fakeBase ' {}');
            }
    Probably it needs to be process in the same way when creating $proxyClass?

    PHP:
                        // XenForo Class Proxy, in case you're wondering
                        
    $proxyClass 'XFCP_' $dynamicClass;
                        
    $namespaceEval '';

                        
    $nsSplit strrpos($dynamicClass'\\');
                        if (
    $nsSplit !== false && $ns substr($dynamicClass0$nsSplit))
                        {
                            
    $namespaceEval "namespace $ns; ";
                            
    $proxyClass 'XFCP_' substr($dynamicClass$nsSplit 1);
                            
    $createClass '\\' $createClass;
                        }

                        eval(
    $namespaceEval 'class ' $proxyClass ' extends ' $createClass ' {}');
     
  2. Mike

    Mike XenForo Developer Staff Member

    I know I made some changes before, but I don't think I'm going to change this. I have rejected other namespace related changes given that XF is still fundamentally not built with namespaces so becoming namespace-aware is generally out of the current scope. Additionally, the class passed in is usually considered to be an XF class (or at least XF-like) and thus wouldn't be using namespaces. By default, the only place where this path is triggered is view classes (I believe).
     
    Nobita.Kun likes this.
  3. xfrocks

    xfrocks Well-Known Member

    I see your point. And yes, I encountered this issue with a view class from another add-on. Probably keep it in mind when you finally support namespace in XenForo 2.0 then?

    @Nobita.Kun: probably you need to stop using namespaces until the core software supports it ;)
     
    Nobita.Kun likes this.
  4. Nobita.Kun

    Nobita.Kun Well-Known Member

    Yep! I've try another way for that :oops:
    Hope that 2.0 support full namespaces :)
     

Share This Page