XML Sitemap for XenForo 1.3 [Not needed, included in 1.4]

Rigel Kentaurus

Well-known member
Problem here version of XF 1.1 and Sitemap 1.1.2B


Code:
Server Error
 
Undefined index: forumsPagination
 
XenForo_Application::handlePhpError() in XfAddOns/Sitemap/Index.php at line 78
XfAddOns_Sitemap_Index->generate() in XfAddOns/Sitemap/CronEntry/RebuildSitemap.php at line 30
XfAddOns_Sitemap_CronEntry_RebuildSitemap::run()
call_user_func() in XenForo/Model/Cron.php at line 356
XenForo_Model_Cron->runEntry() in XenForo/ControllerAdmin/Cron.php at line 204
XenForo_ControllerAdmin_Cron->actionRun() in XenForo/FrontController.php at line 310
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
XenForo_FrontController->run() in /home/tg/public_html/tgforos/admin.php at line 13
Go to sitemap options, and hit save. That should be enough. Looks like the options are not updated.
 

Rigel Kentaurus

Well-known member
Finally end up running it. After about 20 minutes, I figured something was up. This error was in the admin server log about 20,000 times. (If this is a configuration problem, my bad)

Code:
Exception: -- Starting at 69 and page 2 and generating 10000 urls... - /home/miuiandroid/public_html/community/library/XenForo/Error.php:193
Generated By: Unknown Account, Today at 5:05 AM
Stack Trace
#0 /home/miuiandroid/public_html/community/library/XfAddOns/Sitemap/Index.php(157): XenForo_Error::debug('-- Starting at ...')
#1 /home/miuiandroid/public_html/community/library/XfAddOns/Sitemap/Index.php(80): XfAddOns_Sitemap_Index->generateForumsPagination()
#2 /home/miuiandroid/public_html/community/library/XfAddOns/Sitemap/CronEntry/RebuildSitemap.php(30): XfAddOns_Sitemap_Index->generate()
#3 /home/miuiandroid/public_html/community/library/XfAddOns/Sitemap/Cli.php(29): XfAddOns_Sitemap_CronEntry_RebuildSitemap::run()
#4 {main}
Seems like it is caught in an infinite loop. I'll take a look.
 

iBotPeaches

Active member
Code:
        $st = new Zend_Db_Statement_Mysqli($db, $sql);
        $st->execute( array( $this->lastId ) );
 
        $totalPages = 0;
        while ($data = $st->fetch())
        {
            $this->lastId = $data['node_id'];
            if (!$this->canView($data))
            {
                continue;
            }
 
            $totalPages = $this->getTotalpages($data['node_id']);
            if ($totalPages < 2)
            {
                continue;
            }
 
            while ($this->lastPage <= $totalPages)
            {
                $params = array( 'page' => $this->lastPage, );
                $url = XenForo_Link::buildPublicLink('canonical:forums', $data, $params);
                $this->addUrl($url, $data['last_post_date']);
 
                $this->lastPage++;
 
                $totalElements--;
                if ($totalElements <= 0)
                {
                    break 2;
                }
            }
            //$this->lastPage = 2;
        }
 
        $this->isFinished = !$st->fetch() && $this->lastPage > $totalPages;
        $st->closeCursor();
    }
ForumPagination.php

This block of code fixes the CLI issue. I don't know what effects it has elsewhere. I just commented out $this->lastPage =2, because otherwise it never can throw isFinished() and re-loops.

Then if you have "pinging" enabled. On my copy during a CLI test this was encountered.

Code:
An exception occurred: sprintf(): Too few arguments in XenForo/Error.php on line                        193
#0 [internal function]: XenForo_Application::handlePhpError(2, 'sprintf(): Too .                      ..', '/home/miuiandro...', 193, Array)
#1 [internal function]: sprintf('Pinging to Goog...')
#2 XenForo/Error.php(193): call_user_func_array('sprintf', Array)
#3 XfAddOns/Sitemap/Helper/Ping.php(46): XenForo_Error::debug('Pinging to Goog..                      .')
#4 XfAddOns/Sitemap/Index.php(133): XfAddOns_Sitemap_Helper_Ping::pingGoogle('ht                      tp://miuiandr...')
#5 XfAddOns/Sitemap/Index.php(93): XfAddOns_Sitemap_Index->pingServices()
#6 XfAddOns/Sitemap/CronEntry/RebuildSitemap.php(30): XfAddOns_Sitemap_Index->ge                      nerate()
#7 XfAddOns/Sitemap/Cli.php(29): XfAddOns_Sitemap_CronEntry_RebuildSitemap::run(                      )
#8 {main}
 

Rigel Kentaurus

Well-known member
Yeah, it's a small bug in ForumPagination. I caught it yesterday but couldn't upgrade the add-on. Actually the fix I am doing is. Instead of

Code:
    /**
    * Append the information about the forums to the sitemap
    */
    public function generate($totalElements)
    {
        $this->initialize();
 
        $db = XenForo_Application::getDb();
        $sql = "
            SELECT * FROM xf_node node
            INNER JOIN xf_forum forum ON node.node_id=forum.node_id
            WHERE
                node.node_id >= ?
            ORDER BY
                node.node_id
            ";
Change that to

Code:
    /**
    * Append the information about the forums to the sitemap
    */
    public function generate($totalElements)
    {
        $this->initialize();
 
        $db = XenForo_Application::getDb();
        $sql = "
            SELECT * FROM xf_node node
            INNER JOIN xf_forum forum ON node.node_id=forum.node_id
            WHERE
                node.node_id > ?
            ORDER BY
                node.node_id
            ";

The change is that instead of >= is just >
subtle but relevant
 

Rigel Kentaurus

Well-known member
I uploaded the fixed version. Thanks for testing it. Somehow nobody has caught this bug, I am guessing that was because nobody had actually generated a sitemap with more than 10000 forums+pages. You must have a lot of threads.
 

Biirds

Member
Hi! I get this error when upgrading (could it be because I haven't so many posts so there are no paginations in my forum)?:

Server Error

Undefined index: forumsPagination
  1. XenForo_Application::handlePhpError() in XfAddOns/Sitemap/Index.php at line 78
  2. XfAddOns_Sitemap_Index->generate() in XfAddOns/Sitemap/CronEntry/RebuildSitemap.php at line 30
  3. XfAddOns_Sitemap_CronEntry_RebuildSitemap::run() in XenForo/Model/Cron.php at line 356
  4. XenForo_Model_Cron->runEntry() in XenForo/ControllerAdmin/Cron.php at line 204
  5. XenForo_ControllerAdmin_Cron->actionRun() in XenForo/FrontController.php at line 310
  6. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  7. XenForo_FrontController->run() in /home/biirds/public_html/admin.php at line 13

Does it still work as it should?
 
Hi,

I'm getting the following error when creating a sitemap on my site. What should I do?

Stack Trace
#0 /home/
*****/domains/*****.net/public_html/forum/library/XfAddOns/Sitemap/CronEntry/RebuildSitemap.php(30): XfAddOns_Sitemap_Index->generate()
#1 [internal function]: XfAddOns_Sitemap_CronEntry_RebuildSitemap::run(Array)
#2 /home/*****/domains/
*****.net/public_html/forum/library/XenForo/Model/Cron.php(356): call_user_func(Array, Array)
#3 /home/
*****/domains/*****.net/public_html/forum/library/XenForo/ControllerAdmin/Cron.php(204): XenForo_Model_Cron->runEntry(Array)
#4 /home/
*****/domains/*****.net/public_html/forum/library/XenForo/FrontController.php(310): XenForo_ControllerAdmin_Cron->actionRun()
#5 /home/
*****/domains/*****.net/public_html/forum/library/XenForo/FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#6 /home/
*****/domains/*****.net/public_html/forum/admin.php(13): XenForo_FrontController->run()
#7 {main}


Request State

array(3) {
["url"] => string(135) "http://www.
*****.net/forum/admin.php?cron/cemzoo_rebuild_sitemap/run&_xfToken=1%2C1329331962%2C6cb23f952e957359d3236ac354d16bfa9280e953"
["_GET"] => array(2) {
["cron/cemzoo_rebuild_sitemap/run"] => string(0) ""
["_xfToken"] => string(53) "1,1329331962,6cb23f952e957359d3236ac354d16bfa9280e953"
}
["_POST"] => array(0) {
}
}
 

Rigel Kentaurus

Well-known member
Do you have anything else in your server log? That error does not give me much information to figure out the problem, other than making sure all the files were uploaded correctly.
 
Sitemap by removing the previous version installed v112c one from scratch.The server error i wrote above recorddoes not show anything else. Will be allowed towriteto any folder?
 

Rigel Kentaurus

Well-known member
Sitemap by removing the previous version installed v112c one from scratch.The server error i wrote above recorddoes not show anything else. Will be allowed towriteto any folder?
Oh, I see.
Yes, per the instructions you need to chmod for write access the "sitemap" directory that you should have under your xenforo installation. Otherwise this will not work. You don't need to give write access to everything, just to the sitemap directory
 

iBotPeaches

Active member
I'm back lol.


Missing XML tag
This required tag is missing. Please add it and resubmit.
That sitemap it refers to
sitemap.forums.pags.2.xml.gz

Has only these contents.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"/>
All those sitemaps files are 0777. It generated the other ones fine. I just don't know why this one came out empty. Turns out I don't need the CLI version. The only reason the web based cron was timing out was because of that threadPagination bug you fixed making/testing the CLI version.
 

Rigel Kentaurus

Well-known member
I'm back lol.




That sitemap it refers to
sitemap.forums.pags.2.xml.gz

Has only these contents.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"/>
All those sitemaps files are 0777. It generated the other ones fine. I just don't know why this one came out empty. Turns out I don't need the CLI version. The only reason the web based cron was timing out was because of that threadPagination bug you fixed making/testing the CLI version.
For some reason that particular sitemap is empty. You could get rid of it if in the options you disable the "Forum pages" option, it would not even be generated
However, if you have public forums, with more than 1 page... then that is an error
 

iBotPeaches

Active member
For some reason that particular sitemap is empty. You could get rid of it if in the options you disable the "Forum pages" option, it would not even be generated
However, if you have public forums, with more than 1 page... then that is an error
Yeah lol, I have public forums with more than 1 page. I'm pretty sure its a bug, I'll go investigating again soon.
 
Top