Notice: Undefined property: stdClass::$comment_count in tracker_page() (line 52 of /www/www-staging/drupal.sandbox.sanger.ac.uk/htdocs/modules/tracker/tracker.pages.inc).
Notice: Undefined property: stdClass::$type in tracker_page() (line 62 of /www/www-staging/drupal.sandbox.sanger.ac.uk/htdocs/modules/tracker/tracker.pages.inc).
Notice: Undefined property: stdClass::$title in tracker_page() (line 63 of /www/www-staging/drupal.sandbox.sanger.ac.uk/htdocs/modules/tracker/tracker.pages.inc).
Notice: Undefined property: stdClass::$last_activity in tracker_page() (line 66 of /www/www-staging/drupal.sandbox.sanger.ac.uk/htdocs/modules/tracker/tracker.pages.inc).

Comments

zozodesbois’s picture

Hello,
I have same messages with the tracker into Drupal 7.9...
Regards

Notice : Undefined property: stdClass::$last_activity dans tracker_page() (ligne 94 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$comment_count dans tracker_page() (ligne 93 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$last_activity dans tracker_page() (ligne 92 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$comment_count dans tracker_page() (ligne 87 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$type dans tracker_page() (ligne 73 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$last_activity dans tracker_page() (ligne 66 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$title dans tracker_page() (ligne 63 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$type dans tracker_page() (ligne 62 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
Notice : Undefined property: stdClass::$comment_count dans tracker_page() (ligne 52 dans /home/web/NL-5336/geekyhmb/www/modules/tracker/tracker.pages.inc).
stephenrobinson’s picture

Hi,
Debug of $nodes looks like this, not all nodes have a entry in node_comment_statistics to join with...

    [459] => stdClass Object
        (
            [nid] => 459
            [changed] => 1320829976
        )

    [3698] => stdClass Object
        (
            [nid] => 3698
            [title] => Mark Youles
            [type] => user
            [changed] => 1320818589
            [uid] => 1
            [name] => Admin
            [comment_count] => 0
            [last_activity] => 1320818589
        )
catch’s picture

Component: base system » node.module
Status: Active » Postponed (maintainer needs more info)

This looks like invalid nodes rather than a bug in tracker module.

Are all those nodes created via the UI, or have you created them with a migration script or similar? What contrib modules are installed?

Note that devel has a command "devel_rebuild_node_comment_statistics()" (might not be named exactly like that), which can repair this table.

stephenrobinson’s picture

This was a D5, there is a comment on how to do this in D7 at http://drupal.org/node/137458#comment-5072066, will try adding this to my upgrade module .install

stephenrobinson’s picture

also see http://api.lullabot.com/devel_rebuild_node_comment_statistics/7

<?php
function devel_rebuild_node_comment_statistics() {
  // Empty table
  db_truncate('node_comment_statistics')->execute();

  // TODO: DBTNG. Ignore keyword is Mysql only? Is only used in the rare case when
  // two comments on the same node share same timestamp.
  $sql = "
    INSERT IGNORE INTO {node_comment_statistics} (nid, cid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) (
      SELECT c.nid, c.cid, c.created, c.name, c.uid, c2.comment_count FROM {comment} c
      JOIN (
        SELECT c.nid, MAX(c.created) AS created, COUNT(*) AS comment_count FROM {comment} c WHERE status = 1 GROUP BY c.nid
      ) AS c2 ON c.nid = c2.nid AND c.created = c2.created
    )";
  db_query($sql, array(':published' => COMMENT_PUBLISHED));

  // Insert records into the node_comment_statistics for nodes that are missing.
  $query = db_select('node', 'n');
  $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid');
  $query->addField('n', 'changed', 'last_comment_timestamp');
  $query->addField('n', 'uid', 'last_comment_uid');
  $query->addField('n', 'nid');
  $query->addExpression('0', 'comment_count');
  $query->addExpression('NULL', 'last_comment_name');
  $query->isNull('ncs.comment_count');

  db_insert('node_comment_statistics')
    ->from($query)
    ->execute();
}
?>
zozodesbois’s picture

Yes it's certainly due to an upgrade because I began my site with Drupal 7.0 and I applied all upgrades.
I don't understand, in which file do I put this function ?
Regards

stephenrobinson’s picture

you could just try making a php page and past devel_rebuild_node_comment_statistics(); into it? Assuming you have the devel module installed and enabled.

zozodesbois’s picture

Hello SangersDrupalDude,
I have installed devel module and it's enabled.
(I play with the devel options and I have activated the devel block...)

I found the function you have mentioned before "devel_rebuild_node_comment_statistics()" at the end of the file devel.module

I have created a php page with your 3 lines.
I named it "devel_rebuild.php"

but wamp return me this message
Fatal error: Call to undefined function devel_rebuild_node_comment_statistics() in C:\wamp\www\GeekyHMB\devel_rebuild.php on line 2

Thanks for your help.
Zozodesbois

zozodesbois’s picture

I found the devel/php page, I put only the function name:
devel_rebuild_node_comment_statistics();
It's okay now, the notifications disappear into the tracker
Thanks

zozodesbois’s picture

Sorry but, errors are still there...
I found into the tracker:

Anonymous (non vérifié) 0 Il y a 41 années 11 mois
Anonymous (non vérifié) 0 Il y a 41 années 11 mois

I think I must use the devel trace to found these entries and delete them in phpMyAdmin ...
Is it the good way ?

stephenrobinson’s picture

I made a hook to fix this in D7.12 as old attempts didnt work with this version:

/**
 * Repair node comment statistics
 */ 
function postmigrate_update_7007() {
  db_truncate('node_comment_statistics')->execute();
  $query = db_select('node', 'n');
  $query->addField('n', 'nid');
  $query->addField('n', 'created');
  $query->condition('status', 1, '=');
  $query->condition('nid', 0, '>');
  $query->orderBy('nid', 'ASC');
  $records = $query->execute();
  foreach ($records as $record) { 
    $last_comment_timestamp = $record->created;
    $last_comment_uid = 1;
    $comment_count = 0;
    $cid = 0;
    $last_comment_uid = 0;
    $query2 = db_select('comment', 'c');
    $query2->addField('c', 'changed');
    $query2->addField('c', 'uid');
    $query2->addField('c', 'status');
    $query2->addField('c', 'cid');
    $query2->condition('status', 1, '=');
    $query2->condition('nid', $record->nid, '=');
    $query2->orderBy('nid', 'ASC');
    $query2->orderBy('cid', 'ASC');
    $commrecords = $query2->execute();
    foreach ($commrecords as $commrecord) { 
      $comment_count++;
      $last_comment_uid = $commrecord->uid;
      $cid = $commrecord->cid;
      $last_comment_timestamp = $commrecord->changed;
    }
    if($last_comment_uid == 0){
      $last_comment_uid = 1;
    }
    $query3 = db_merge('node_comment_statistics')->key(
      array(
        'nid' => (int) $record->nid,
      )
    )->fields(
      array(
        'nid' => (int) $record->nid,
        'last_comment_timestamp' => (string) $last_comment_timestamp,
        'last_comment_name' => NULL,
        'last_comment_uid' => (int) $last_comment_uid,
        'comment_count' => (int) $comment_count,
        'cid' => (int) $cid,
      )
    )->execute(); 
  }
  watchdog('postmigrate', 'update_7007 - repaired node comment statistics (breaks tracker).');
  return 'update_7007 - repaired node comment statistics (breaks tracker).';
}
katehsu888’s picture

Version: 7.9 » 7.12

Hi there,

I'm not a programmer and can't understand the above solutions.
Where to put the scripts? Or any other method to fix the following error
when viewing "q=tracker" for non-programmer please?

Notice: Undefined property: stdClass::$comment_count in tracker_page() (line 52 of C:\wamp\www\Drupal\modules\tracker\tracker.pages.inc).Notice: Undefined property: stdClass::$type in tracker_page() (line 62 of C:\wamp\www\Drupal\modules\tracker\tracker.pages.inc).Notice: Undefined property: stdClass::$title in tracker_page() (line 63 of C:\wamp\www\Drupal\modules\tracker\tracker.pages.inc).

I appreciate your quick response.

mschelstrate’s picture

When I try to run this script I receive an error because the table in my Drupal database is named "Comments" with an "s" on the end.
The query is using "Comment" as the table name.
What is the correct table name?
My installation as upgraded form Drupal6.
Should the table have been renamed during the upgrade?

stephenrobinson’s picture

My table is named comment?
Stephen :)

andres_de’s picture

I recently had those errors on my site too. (/tracker/1)
I found out that they showed up because I forgot to uninstall the module tracker when I disabled it a while ago.
After re enabling it now I saw those errors because meanwhile some nodes have been deleted, but they still appeared in the db-table tracker_node.
Solution:
1. disable AND uninstall the module tracker
2. re enable it, and I my case the errors were gone.

zozodesbois’s picture

Thanks Andres_de !
It's good for me.
Now tracker give no error.
Regards

zozodesbois’s picture

Issue summary: View changes

missed a line

Version: 7.12 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Postponed (maintainer needs more info) » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.