Problem
After you have installed and configured the module, cron queries the different social networks asking for the times that a node has been shared.
But after the first time a node get queued for the update of this information, it would remain in this state, even after the social networks are consulted.
If you check at the social_stats_total table, you can see it has not benn updated. total_virality is empty, changed is NULL and queued 1.
This makes that at the next run of cron, the node will not be queued again for a new query.
Watching at the code, I have seen that the queued value is set to 0 (zero) again, only for the first item in the queue, and only if it has some shares in any of the social networks.
if (empty($batch['unfetched_services'])) {
$item = reset($batch['items']);
if ($item->social_stats != NULL) {
$count_total = array_sum($item->social_stats);
db_merge('social_stats_total')
->key(array('nid' => $item->nid))
->fields(array(
'total_virality' => $count_total,
'changed' => REQUEST_TIME,
'queued' => 0,
))
->execute();
}
}
The rest of the nodes are leaved as queued, but there is no item in Drupal's queue that updates its information.
Proposed resolution
I think the best option, without changing the current logic of the function _social_stats_update, is to restore the queued value to zero after the execution of the callback function of every social network, right after the foreach that start at line 334.
Comment | File | Size | Author |
---|---|---|---|
#3 | stats_only_update_once-2478791-2.patch | 3.44 KB | AjitS |
#1 | stats_only_update_once-2478791-1.patch | 3.47 KB | tucho |
Comments
Comment #1
tuchoI have attached a patch implementing my proposed solution. After querying the social networks, the nodes will be marked as not queued.
I have added the fields of the stats for every network to the query at the function social_stats_cron, so the value is not lost if the queries are continued on another queue run.
Comment #3
AjitSThank you for reporting the issue and for the patch.
I tested it and it worked fine. Applied the patch, cleaned up minor coding standard issues and committed it to the 7.x-1.x branch. Thanks!