[Suggest] fix rating mod for Web Crawler

JoeHornTW

Joined: 2009-10-04
Posts: 2
Posted: Sun, 2009-10-04 21:10

I am using Gallery 2.3, and I found these messages in my Apache error logs:

Quote:
[Mon Oct 05 04:26:42 2009] [error] [client 66.249.68.135] PHP Notice: Undefined index: itemId in /System/Gallery/modules/rating/RatingCallback.inc on line 88
[Mon Oct 05 04:26:42 2009] [error] [client 66.249.68.135] PHP Notice: Undefined index: rating in /System/Gallery/modules/rating/RatingCallback.inc on line 89
[Mon Oct 05 04:26:42 2009] [error] [client 66.249.68.135] PHP Notice: Undefined index: userRating in /System/Gallery/modules/rating/RatingCallback.inc on line 91

The FQDN for 66.249.68.135 is crawl-66-249-68-135.googlebot.com .

Obviously, crawlers can't run javascript, so they can't execute these code in modules/rating/rating.js:

Quote:
function updateItemRating(results) {
var itemId = results[0];
var rating = results[1];
var votes = results[2];
var userRating = results[3];
galleryAuthToken = results[4];

updateElementDisplay('rating.rating.' + itemId, rating);
updateElementDisplay('rating.votes.' + itemId, votes);
updateElementDisplay('rating.userRating.' + itemId, userRating);
updateAveragePercent(itemId, rating * 100 / 5);

resetStarDisplay(itemId);
}

But they still touch modules/rating/RatingCallback.inc, so I suggest that chnage these code:

Quote:
$session =& $gallery->getSession();
print $results['itemId'] . "\n"
. $results['rating'] . "\n"
. $results['votesString'] . "\n"
. $results['userRating'] . "\n"
. $session->getAuthToken();

to these:

Quote:
$session =& $gallery->getSession();

if ( isset($results['itemId']) && isset($results['rating']) && isset($results['userRating']) ) {
print $results['itemId'] . "\n"
. $results['rating'] . "\n"
. $results['votesString'] . "\n"
. $results['userRating'] . "\n"
. $session->getAuthToken();
}