From: Brion Vibber Date: Sat, 12 Feb 2011 01:10:48 +0000 (+0000) Subject: * (bug 27333) Fix repetitive last-seen time queries on page history X-Git-Tag: 1.31.0-rc.0~32032 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=0344a7787eb78c36fc0283337ab020911723419d;p=lhc%2Fweb%2Fwiklou.git * (bug 27333) Fix repetitive last-seen time queries on page history Title::getNotificationTimestamp() is called for every line in HistoryPager, to compare against the revision's timestamp to determine if it's a new edit since the viewer's last visit to the page. The function kept an internal cache within the Title object to avoid having to make the query over and over in this situation, but in the case that it returns null, the cached entry would be accidentally ignored on the next round due to use of isset() to check for the array entry. (Most of the time it's great, but if the value of the key actually *is* null, isset() returns false.) Switched to array_key_exists(), which doesn't have this false negative. Now only one query gets issued for this on a history page, even if the answer is null. --- diff --git a/includes/Title.php b/includes/Title.php index dfadd7ac85..a0b36e83cd 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3870,7 +3870,8 @@ class Title { } // Check cache first $uid = $user->getId(); - if ( isset( $this->mNotificationTimestamp[$uid] ) ) { + // avoid isset here, as it'll return false for null entries + if ( array_key_exists( $uid, $this->mNotificationTimestamp ) ) { return $this->mNotificationTimestamp[$uid]; } if ( !$uid || !$wgShowUpdatedMarker ) {