r82607 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82606‎ | r82607 | r82608 >
Date:15:32, 22 February 2011
Author:thomasv
Status:ok
Tags:
Comment:
check that variables are defined
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -460,7 +460,7 @@
461461 }
462462
463463 if ( count( $values ) ) {
464 - $query .= "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(" . implode( ",", $values ) . ")";
 464+ $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(" . implode( ",", $values ) . ")";
465465 $res = $dbr->query( $query, __METHOD__ );
466466
467467 foreach ( $res as $x ) {
@@ -670,14 +670,8 @@
671671 $name = $imageTitle->getDBkey();
672672 $count = $image->pageCount();
673673
674 - $from = $args['from'];
675 - $to = $args['to'];
676 - if( !$from ) {
677 - $from = 1;
678 - }
679 - if( !$to ) {
680 - $to = $count;
681 - }
 674+ $from = array_key_exists( 'from', $args ) ? $args['from'] : 1;
 675+ $to = array_key_exists( 'to', $args ) ? $args['to'] : $count;
682676
683677 if( !is_numeric( $from ) || !is_numeric( $to ) ) {
684678 return '<strong class="error">' . wfMsgForContent( 'proofreadpage_number_expected' ) . '</strong>';
@@ -721,11 +715,12 @@
722716 function renderPages( $input, $args, $parser ) {
723717 $page_namespace = $this->page_namespace;
724718 $index_namespace = $this->index_namespace;
725 - $index = $args['index'];
726 - $from = $args['from'];
727 - $to = $args['to'];
728 - $header = $args['header'];
729719
 720+ $index = array_key_exists( 'index', $args ) ? $args['index'] : null;
 721+ $from = array_key_exists( 'from', $args ) ? $args['from'] : null;
 722+ $to = array_key_exists( 'to', $args ) ? $args['to'] : null;
 723+ $header = array_key_exists( 'header', $args ) ? $args['header'] : null;
 724+
730725 // abort if the tag is on an index page
731726 if ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $parser->Title()->getPrefixedText() ) ) {
732727 return '';
@@ -918,23 +913,23 @@
919914 if( isset( $args['next'] ) ) {
920915 $next = $args['next'];
921916 }
922 - if( $current ) {
 917+ if( isset( $current ) ) {
923918 $h_out .= "|current=$current";
924919 }
925 - if( $prev ) {
 920+ if( isset( $prev ) ) {
926921 $h_out .= "|prev=$prev";
927922 }
928 - if( $next ) {
 923+ if( isset( $next ) ) {
929924 $h_out .= "|next=$next";
930925 }
931 - if( $from_pagenum ) {
 926+ if( isset( $from_pagenum ) ) {
932927 $h_out .= "|from=$from_pagenum";
933928 }
934 - if( $to_pagenum ) {
 929+ if( isset( $to_pagenum ) ) {
935930 $h_out .= "|to=$to_pagenum";
936931 }
937932 foreach ( $attributes as $key => $val ) {
938 - if( $args[$key] ) {
 933+ if( array_key_exists( $key, $args ) ) {
939934 $val = $args[$key];
940935 }
941936 $h_out .= "|$key=$val";

Status & tagging log