Page count in Full Sitemap very large

Permalink
Hi

A page count in a site has gone mental, its reading 4294967266 - see attached.

Can this be fixed/reset?

Thanks

1 Attachment

yolk
 
mkly replied on at Permalink Reply
mkly
Hello,
It is kept in the database in the Pages table as cChildren.

You can reset this either with a db query or create a tools file like the one below and browse to it like
http://example.com/index.php/tools/reset_count

With the code(you will need to edit this for your site) and save it to the root tools/ directory
/tools/reset_count.php

<?php
// The path for page
$path  = '/path/to/page/';
// The count you want to set this to
$count = 50;
//
//
Loader::db(
  'UPDATE Pages SET cChildren = ? WHERE cID = ?',
  array(
    $count,
    Page::getByPath($path)->getCollectionID()
  )
);


As always please back up your database beforehand and this code comes with no warranty but with best intentions.

Best Wishes,
Mike
yolk replied on at Permalink Reply
yolk
Thanks mkly, I can reset the db record fine, but what is stopping it from calculating it wrong again?
mkly replied on at Permalink Best Answer Reply
mkly
I'm not sure. That looks like an unsigned integer that went below zero and wrapped around. Which basiclally means it became less than zero.

I made a quick change that will at least prevent the very large number and instead end decrementing at 0.

EDIT:https://github.com/concrete5/concrete5/pull/1338...

As to why this is happening in your setup, I'm not sure.

The method that decrements that number PageStatistics::decrementParents() gets called in Page::move(), Page::delete() and Page::removeAlias()

So if there is anything strage(maybe page events) that may be happening to get in the way of that, I would look there.

Best Wishes,
Mike
yolk replied on at Permalink Reply
yolk
Thanks mkly, I reset the number of cChildren to the real number, in the hope that the + and - functions will just take care of the rest.

Thanks.