r23975 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23974‎ | r23975 | r23976 >
Date:21:16, 10 July 2007
Author:brion
Status:old
Tags:
Comment:
Fix a bug where PHP warnings got spewed when handling the final request in a sequence where we're using resumption tokens, but there's nothing left to resume at. The local variable $token was being used for two different tasks, and the already-set variable was misdetected.
Modified paths:
  • /trunk/extensions/OAI/OAIRepo_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OAI/OAIRepo_body.php
@@ -437,15 +437,15 @@
438438 function listRecords( $verb ) {
439439 $withData = ($verb == 'ListRecords');
440440
441 - $token = $this->validateToken( 'resumptionToken' );
 441+ $startToken = $this->validateToken( 'resumptionToken' );
442442 if( $this->errorCondition() ) {
443443 return;
444444 }
445 - if( $token ) {
446 - $metadataPrefix = $token['metadataPrefix'];
447 - $resume = $token['resume'];
 445+ if( $startToken ) {
 446+ $metadataPrefix = $startToken['metadataPrefix'];
 447+ $resume = $startToken['resume'];
448448 $from = null;
449 - $until = $token['until'];
 449+ $until = $startToken['until'];
450450 } else {
451451 $metadataPrefix = $this->validateMetadata( 'metadataPrefix' );
452452 $resume = null;
@@ -475,9 +475,9 @@
476476 if( $row = $resultSet->fetchObject() ) {
477477 $limit = wfTimestamp( TS_MW, $until );
478478 if( $until )
479 - $token = "$metadataPrefix:$row->up_sequence:$limit";
 479+ $nextToken = "$metadataPrefix:$row->up_sequence:$limit";
480480 else
481 - $token = "$metadataPrefix:$row->up_sequence";
 481+ $nextToken = "$metadataPrefix:$row->up_sequence";
482482 }
483483 $resultSet->free();
484484 // init writer
@@ -491,8 +491,8 @@
492492 echo $item->renderHeader( $this->timeGranularity() );
493493 }
494494 }
495 - if( isset($token) ) {
496 - echo oaiTag( 'resumptionToken', array(), $token ) . "\n";
 495+ if( isset( $nextToken ) ) {
 496+ echo oaiTag( 'resumptionToken', array(), $nextToken ) . "\n";
497497 }
498498 echo "</$verb>\n";
499499 } else {

Status & tagging log