r90151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90150‎ | r90151 | r90152 >
Date:20:52, 15 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
address bug 29419
Modified paths:
  • /trunk/extensions/Maps/includes/Maps_CoordinateParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/Maps_CoordinateParser.php
@@ -528,17 +528,28 @@
529529 if ( $isNegative ) $coordinate = substr( $coordinate, 1 );
530530
531531 $degreePosition = strpos( $coordinate, self::SYMBOL_DEG );
 532+ $degrees = substr ( $coordinate, 0, $degreePosition );
 533+
532534 $minutePosition = strpos( $coordinate, self::SYMBOL_MIN );
533 - $secondPosition = strpos( $coordinate, self::SYMBOL_SEC );
534535
535 - $degSignLength = strlen( self::SYMBOL_DEG );
 536+ if ( $minutePosition === false ) {
 537+ $minutes = 0;
 538+ }
 539+ else {
 540+ $degSignLength = strlen( self::SYMBOL_DEG );
 541+ $minuteLength = $minutePosition - $degreePosition - $degSignLength;
 542+ $minutes = substr ( $coordinate, $degreePosition + $degSignLength, $minuteLength );
 543+ }
536544
537 - $minuteLength = $minutePosition - $degreePosition - $degSignLength;
538 - $secondLength = $secondPosition - $minutePosition - 1;
 545+ $secondPosition = strpos( $coordinate, self::SYMBOL_SEC );
539546
540 - $degrees = substr ( $coordinate, 0, $degreePosition );
541 - $minutes = substr ( $coordinate, $degreePosition + $degSignLength, $minuteLength );
542 - $seconds = substr ( $coordinate, $minutePosition + 1, $secondLength );
 547+ if ( $minutePosition === false ) {
 548+ $seconds = 0;
 549+ }
 550+ else {
 551+ $secondLength = $secondPosition - $minutePosition - 1;
 552+ $seconds = substr ( $coordinate, $minutePosition + 1, $secondLength );
 553+ }
543554
544555 $coordinate = $degrees + ( $minutes + $seconds / 60 ) / 60;
545556 if ( $isNegative ) $coordinate *= -1;

Follow-up revisions

RevisionCommit summaryAuthorDate
r90153MFT r90151 and r90152jeroendedauw20:55, 15 June 2011

Status & tagging log