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

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:
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?
 
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.
 
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:
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...
 
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/
 
@Chris D, everything looks OK:
| resource | XenResource | a:5:{s:30:"moderation_queue_handler_class";s:43:"XenResource_ModerationQueueHandler_Resource";s:27:"moderator_log_handler_class";s:40:"XenResource_ModeratorLogHandler_Resource";s:21:"sitemap_handler_class";s:35:"XenResource_SitemapHandler_Resource";s:18:"spam_handler_class";s:32:"XenResource_SpamHandler_Resource";s:19:"stats_handler_class";s:33:"XenResource_StatsHandler_Resource";} |
| article | XenArticle | a:5:{s:30:"moderation_queue_handler_class";s:41:"XenArticle_ModerationQueueHandler_Article";s:27:"moderator_log_handler_class";s:38:"XenArticle_ModeratorLogHandler_Article";s:21:"sitemap_handler_class";s:33:"XenArticle_SitemapHandler_Article";s:18:"spam_handler_class";s:30:"XenArticle_SpamHandler_Article";s:19:"stats_handler_class";s:31:"XenArticle_StatsHandler_Article";} |
 
Are you sure the file library/XenArticle/SitemapHandler/Article.php actually exists and it has the correct class name defined in the PHP file?
 
Top Bottom