r37531 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37530‎ | r37531 | r37532 >
Date:20:32, 10 July 2008
Author:jeluf
Status:old
Tags:
Comment:
Check 'isset' before accessing array elements
Modified paths:
  • /trunk/extensions/SlippyMap/SlippyMap.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SlippyMap/SlippyMap.class.php
@@ -27,13 +27,41 @@
2828
2929 wfLoadExtensionMessages( 'SlippyMap' );
3030
31 - $lat = $argv['lat'];
32 - $lon = $argv['lon'];
33 - $zoom = $argv['z'];
34 - $width = $argv['w'];
35 - $height = $argv['h'];
36 - $layer = $argv['layer'];
37 - $marker = $argv['marker'];
 31+ if ( isset( $argv['lat'] ) ) {
 32+ $lat = $argv['lat'];
 33+ } else {
 34+ $lat = '';
 35+ }
 36+ if ( isset( $argv['lon'] ) ) {
 37+ $lon = $argv['lon'];
 38+ } else {
 39+ $lon = '';
 40+ }
 41+ if ( isset( $argv['z'] ) ) {
 42+ $zoom = $argv['z'];
 43+ } else {
 44+ $zoom = '';
 45+ }
 46+ if ( isset( $argv['w'] ) ) {
 47+ $width = $argv['w'];
 48+ } else {
 49+ $width = '';
 50+ }
 51+ if ( isset( $argv['h'] ) ) {
 52+ $height = $argv['h'];
 53+ } else {
 54+ $height = '';
 55+ }
 56+ if ( isset( $argv['layer'] ) ) {
 57+ $layer = $argv['layer'];
 58+ } else {
 59+ $layer = '';
 60+ }
 61+ if ( isset( $argv['marker'] ) ) {
 62+ $marker = $argv['marker'];
 63+ } else {
 64+ $marker = '';
 65+ }
3866
3967 $error="";
4068
@@ -42,7 +70,9 @@
4371 if ($height=='') $height='320';
4472 if ($layer=='') $layer='mapnik';
4573
46 - if ($zoom=='') $zoom = $argv['zoom']; //see if they used 'zoom' rather than 'z' (and allow it)
 74+ if ($zoom=='' && isset( $argv['zoom'] ) ) {
 75+ $zoom = $argv['zoom']; //see if they used 'zoom' rather than 'z' (and allow it)
 76+ }
4777
4878 $marker = ( $marker != '' && $marker != '0' );
4979
@@ -54,7 +84,6 @@
5585 if ( $lat=='' ) $error .= wfMsg( 'slippymap_latmissing' );
5686 if ( $lon=='' ) $error .= wfMsg( 'slippymap_lonmissing' );
5787 if ( $zoom=='' ) $error .= wfMsg( 'slippymap_zoommissing' );
58 - if ( isset( $argv['long'] ) ) $error .= wfMsg( 'slippymap_longdepreciated' );
5988
6089 if ($error=='') {
6190 //no errors so far. Now check the values

Status & tagging log