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

Not a Bug XF 1.4.1: Class name must be a valid object or a string

Discussion in 'Resolved Bug Reports' started by Floren, Oct 5, 2014.

  1. Floren

    Floren Well-Known Member

    When I try to rebuild any cache, I get this error:
    Code:
    ErrorException: Fatal Error: Class name must be a valid object or a string -
    library/XenForo/Deferred/Sitemap.php:88
    
         87                         $handlerClass = XenForo_Application::resolveDynamicClass($allContentTypes[$contentType]);
         88                         $handler = new $handlerClass();
    Running on PHP 5.6.0. Reverting back to 1.3.1 addresses the issue.
     
    Last edited: Oct 5, 2014
  2. Chris D

    Chris D XenForo Developer Staff Member

    Do you have any add-ons installed that may have added their own sitemap handlers?

    If you go to Admin CP > Options > XML Sitemap Generation what content types are listed there?
     
  3. Floren

    Floren Well-Known Member

    Hi @Chris D,

    I get more errors when I go to that link you suggested:
    Code:
    ErrorException: Fatal Error: Class name must be a valid object or a string -
    library/XenForo/Option/SitemapExclude.php:26
    
    25                        $handlerClass = XenForo_Application::resolveDynamicClass($handlerClass);
    26                        $handler = new $handlerClass();
    Thank you for your help, much appreciated.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    OK.

    Disable all add-ons and then try to go to that link again, do you still get the problem?
     
  5. Floren

    Floren Well-Known Member

    Thanks @Chris D, it was my Articles add-on based on Resources. Where is the check done in Resources to add the sitemap in XenForo? I'll add the same check for Articles. $types returns this:
    Code:
    array(5) {
    ["article"]=>
    string(33) "XenArticle_SitemapHandler_Article"
    ["node"]=>
    string(27) "XenForo_SitemapHandler_Node"
    ["resource"]=>
    string(35) "XenResource_SitemapHandler_Resource"
    ["thread"]=>
    string(29) "XenForo_SitemapHandler_Thread"
    ["user"]=>
    string(27) "XenForo_SitemapHandler_User"
    }
     
    Last edited: Oct 5, 2014
  6. Chris D

    Chris D XenForo Developer Staff Member

    The Resource Manager adds a SitemapHandler to the content_type tables in the database.

    XenForo loads all sitemap_handler_class entries from the database and then displays them on that page so they can be toggled on/off.

    I don't fully understand what the articles add-on code could have done to make this code fall over...
     
  7. Floren

    Floren Well-Known Member

    I think that's the issue, let me check it...
     
  8. Chris D

    Chris D XenForo Developer Staff Member

    Oh I see, your add-on actually adds its own Sitemap? I didn't see your edit until just now.

    The error, then, is basically suggesting the XenArticle_SitemapHandler_Article class doesn't exist or it has some other fault.

    It's worth noting that effectively, the fix due in XF 1.4.2 based on a similar bug report should fix this in the future, in that the invalid Sitemap class would be skipped:

    https://xenforo.com/community/threads/skip-non-existent-sitemap-handler-classes.82922/
     
  9. Floren

    Floren Well-Known Member

    @Chris D, everything looks OK:
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    Are you sure the file library/XenArticle/SitemapHandler/Article.php actually exists and it has the correct class name defined in the PHP file?
     
    Floren likes this.
  11. Floren

    Floren Well-Known Member

    You just nail it @Chris D, many thanks. :D

    articles-sitemap.jpg
     
    MattW and Chris D like this.

Share This Page