r40954 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40953‎ | r40954 | r40955 >
Date:10:22, 17 September 2008
Author:jojo
Status:old
Tags:
Comment:
add session timestamp to timestamp array in OutputPageCheckLastModified hook
Modified paths:
  • /trunk/extensions/Collection/Collection.body.php (modified) (history)
  • /trunk/extensions/Collection/Collection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.php
@@ -95,6 +95,7 @@
9696 $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'Collection::createNavURLs';
9797 $wgHooks['MonoBookTemplateToolboxEnd'][] = 'Collection::insertMonoBookToolboxLink';
9898 $wgHooks['SkinBuildSidebar'][] = 'Collection::buildSidebar';
 99+$wgHooks['OutputPageCheckLastModified'][] = 'Collection::checkLastModified';
99100
100101 # register global Ajax functions:
101102
Index: trunk/extensions/Collection/Collection.body.php
@@ -229,14 +229,12 @@
230230 }
231231
232232 static function clearCollection() {
233 - if ( !self::hasSession() ) {
234 - return;
235 - }
236233 $_SESSION['wsCollection'] = array(
237234 'title' => '',
238235 'subtitle' => '',
239236 'items' => array(),
240237 );
 238+ self::touchSession();
241239 }
242240
243241 static function startSession() {
@@ -246,6 +244,12 @@
247245 self::clearCollection();
248246 }
249247
 248+ static function touchSession() {
 249+ $collection = $_SESSION['wsCollection'];
 250+ $collection['timestamp'] = wfTimestampNow();
 251+ $_SESSION['wsCollection'] = $collection;
 252+ }
 253+
250254 static function countArticles() {
251255 if ( !self::hasSession() ) {
252256 return 0;
@@ -370,6 +374,7 @@
371375 'url' => $title->getFullURL(),
372376 );
373377 $_SESSION['wsCollection'] = $collection;
 378+ self::touchSession();
374379 }
375380
376381 function removeArticle( $title, $oldid=0 ) {
@@ -382,6 +387,7 @@
383388 array_splice( $collection['items'], $index, 1 );
384389 }
385390 $_SESSION['wsCollection'] = $collection;
 391+ self::touchSession();
386392 }
387393
388394 function addCategory( $title ) {
@@ -1452,4 +1458,14 @@
14531459 curl_close( $c );
14541460 return $text;
14551461 }
 1462+
 1463+ /**
 1464+ * OutputPageCheckLastModified hook
 1465+ */
 1466+ static function checkLastModified( $modifiedTimes ) {
 1467+ if ( self::hasSession() ) {
 1468+ $modifiedTimes['collection'] = $_SESSION['wsCollection']['timestamp'];
 1469+ }
 1470+ return true;
 1471+ }
14561472 }