r80807 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80806‎ | r80807 | r80808 >
Date:10:34, 23 January 2011
Author:reedy
Status:ok
Tags:
Comment:
More undefined variables
Modified paths:
  • /trunk/extensions/DoubleWiki/DoubleWiki_body.php (modified) (history)
  • /trunk/extensions/LabeledSectionTransclusion/lst.php (modified) (history)
  • /trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php (modified) (history)
  • /trunk/extensions/OAI/OAIHarvest.php (modified) (history)
  • /trunk/extensions/OAI/OAIRepo_body.php (modified) (history)
  • /trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php (modified) (history)
  • /trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php (modified) (history)
  • /trunk/extensions/SiteMatrix/SiteMatrixApi.php (modified) (history)
  • /trunk/extensions/SpamBlacklist/SpamBlacklist_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OAI/OAIHarvest.php
@@ -284,6 +284,7 @@
285285 }
286286
287287 function getTimestamp( $time ) {
 288+ $matches = array();
288289 if( preg_match( '/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/', $time, $matches ) ) {
289290 return wfTimestamp( TS_MW,
290291 $matches[1] . $matches[2] . $matches[3] .
@@ -759,6 +760,7 @@
760761 */
761762 function oaiNodeMap( $parent, $map ) {
762763 $callMap = array();
 764+ $textMap = array();
763765 foreach( $map as $key => $value ) {
764766 if( is_int( $key ) ) {
765767 $textMap[$value] = true;
@@ -766,7 +768,8 @@
767769 $callMap[$key] = $value;
768770 }
769771 }
770 -
 772+
 773+ $data = array();
771774 foreach( $parent->childNodes as $node ) {
772775 if( $node->nodeType == XML_ELEMENT_NODE ) {
773776 $name = $node->nodeName;
Index: trunk/extensions/OAI/OAIRepo_body.php
@@ -162,6 +162,7 @@
163163 function validateDatestamp( $var ) {
164164 if( isset( $this->_request[$var] ) ) {
165165 $time = $this->_request[$var];
 166+ $matches = array();
166167 if( preg_match( '/^(\d\d\d\d)-(\d\d)-(\d\d)$/', $time, $matches ) ) {
167168 return wfTimestamp( TS_UNIX,
168169 $matches[1] . $matches[2] . $matches[3] . '000000' );
@@ -408,7 +409,9 @@
409410 if( !isset( $this->_request[$var] ) ) {
410411 return null;
411412 }
 413+ $matches = array();
412414 if( preg_match( '/^([a-z_]+):(\d+)(?:|:(\d{14}))$/', $this->_request[$var], $matches ) ) {
 415+ $token = array();
413416 $token['metadataPrefix'] = $matches[1];
414417 $token['resume'] = IntVal( $matches[2] );
415418 $token['until'] = isset( $matches[3] )
Index: trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php
@@ -98,7 +98,8 @@
9999
100100 list( $extract, $badge ) = $this->getExtract( $title );
101101 $image = $this->getBadge( $title, $badge );
102 -
 102+
 103+ $item = array();
103104 $item['Text']['*'] = $title->getPrefixedText();
104105 $item['Description']['*'] = $extract;
105106 $item['Url']['*'] = $title->getFullUrl();
@@ -208,6 +209,7 @@
209210 $end = "(?:$endgroup)";
210211 $sentence = ".*?$end+";
211212 $firstone = "/^($sentence)/u";
 213+ $matches = array();
212214 if( preg_match( $firstone, $text, $matches ) ) {
213215 return $matches[1];
214216 } else {
@@ -224,6 +226,7 @@
225227 function _extractBadge( $text ) {
226228 global $wgContLang;
227229 $image = preg_quote( $wgContLang->getNsText( NS_IMAGE ), '#' );
 230+ $matches = array();
228231 if( preg_match( "#\[\[\s*(?:image|$image)\s*:\s*([^|\]]+)#", $text, $matches ) ) {
229232 return trim( $matches[1] );
230233 } else {
Index: trunk/extensions/LabeledSectionTransclusion/lst.php
@@ -239,6 +239,7 @@
240240
241241 $count = 0;
242242 $offset = 0;
 243+ $m = array();
243244 while ( preg_match( "/$pat/im", $text, $m, PREG_OFFSET_CAPTURE, $offset ) ) {
244245 if ( $m[2][1] > $limit )
245246 break;
@@ -301,6 +302,7 @@
302303 return $text;
303304 $pat = self::getPattern_( $sec, $to );
304305
 306+ $m = array();
305307 if ( preg_match_all( $pat, $text, $m, PREG_OFFSET_CAPTURE ) ) {
306308 $headings = self::countHeadings_( $text, $m[0][0][1] );
307309 } else {
Index: trunk/extensions/SpamBlacklist/SpamBlacklist_body.php
@@ -40,9 +40,9 @@
4141 $thisHttpRegex = '/^' . preg_quote( $thisHttp, '/' ) . '(?:&.*)?$/';
4242
4343 foreach( $this->files as $fileName ) {
 44+ $matches = array();
4445 if ( preg_match( '/^DB: (\w*) (.*)$/', $fileName, $matches ) ) {
4546 if ( $wgDBname == $matches[1] ) {
46 - $sources[] = $matches[2];
4747 if( $matches[2] == $title->getPrefixedDbKey() ) {
4848 // Local DB fetch of this page...
4949 return true;
@@ -122,6 +122,7 @@
123123 # Load lists
124124 wfDebugLog( 'SpamBlacklist', "Constructing spam blacklist\n" );
125125 foreach ( $this->files as $fileName ) {
 126+ $matches = array();
126127 if ( preg_match( '/^DB: ([\w-]*) (.*)$/', $fileName, $matches ) ) {
127128 $text = $this->getArticleText( $matches[1], $matches[2] );
128129 } elseif ( preg_match( '/^http:\/\//', $fileName ) ) {
@@ -228,7 +229,9 @@
229230 $addedLinks = array_diff( $newLinks, $oldLinks );
230231
231232 // We add the edit summary if one exists
232 - if ( !$this->ignoreEditSummary && !empty( $editsummary ) ) $addedLinks[] = $editsummary;
 233+ if ( !$this->ignoreEditSummary && !empty( $editsummary ) ) {
 234+ $addedLinks[] = $editsummary;
 235+ }
233236
234237 wfDebugLog( 'SpamBlacklist', "Old URLs: " . implode( ', ', $oldLinks ) );
235238 wfDebugLog( 'SpamBlacklist', "New URLs: " . implode( ', ', $newLinks ) );
@@ -257,6 +260,7 @@
258261 $retVal = false;
259262 foreach( $blacklists as $regex ) {
260263 wfSuppressWarnings();
 264+ $matches = array();
261265 $check = preg_match( $regex, $links, $matches );
262266 wfRestoreWarnings();
263267 if( $check ) {
Index: trunk/extensions/SiteMatrix/SiteMatrixApi.php
@@ -89,13 +89,11 @@
9090 }
9191
9292 protected function getAllowedParams() {
93 - return array (
94 - );
 93+ return array ();
9594 }
9695
9796 protected function getParamDescription() {
98 - return array (
99 - );
 97+ return array ();
10098 }
10199
102100 protected function getDescription() {
Index: trunk/extensions/DoubleWiki/DoubleWiki_body.php
@@ -36,10 +36,14 @@
3737 * Read the list of matched phrases and add tags to the html output.
3838 */
3939 function addMatchingTags ( &$text, $lang ) {
40 - $pattern = "/<div id=\"align-$lang\" style=\"display:none;\">\n<p>([^<]*?)<\/p>\n<\/div>/is";
41 - if( ! preg_match( $pattern, $text, $m ) ) return ;
 40+ $pattern = "/<div id=\"align-$lang\" style=\"display:none;\">\n<p>([^<]*?)<\/p>\n<\/div>/is";
 41+ $m = array();
 42+ if( ! preg_match( $pattern, $text, $m ) ) {
 43+ return;
 44+ }
4245 $text = str_replace( $m[1], '', $text );
43 - $line_pattern = "/\s*([^:\n]*?)\s*:\s*([^:\n]*?)\s*\n/i";
 46+ $line_pattern = "/\s*([^:\n]*?)\s*:\s*([^:\n]*?)\s*\n/i";
 47+ $items = array();
4448 preg_match_all( $line_pattern, $m[1], $items, PREG_SET_ORDER );
4549 foreach( $items as $n => $i ) {
4650 $text = str_replace( $i[1], "<span id=\"dw-$n\" title=\"{$i[2]}\"/>".$i[1], $text );
@@ -145,6 +149,7 @@
146150 $sub = substr( $right_text, 0, $a);
147151 // detect the end of previous paragraph
148152 // regexp matches the rightmost delimiter
 153+ $m = array();
149154 if ( preg_match("/(.*)<\/(p|dl)>/is", $sub, $m ) ) {
150155 $right_chunk .= $m[0];
151156 $right_text = substr( $right_text, strlen($m[0]) );
@@ -201,6 +206,7 @@
202207 function find_paragraphs( $text ) {
203208 $result = Array();
204209 $bits = preg_split( $this->tags, $text );
 210+ $m = array();
205211 preg_match_all( $this->tags, $text, $m, PREG_SET_ORDER);
206212 $counter = 0;
207213 $out = '';
@@ -231,6 +237,7 @@
232238
233239 $tag_pattern = "/<span id=\"dw-[^\"]*\" title=\"([^\"]*)\"\/>/i";
234240 $left_slices = preg_split( $tag_pattern, $left_text );
 241+ $left_tags = array();
235242 preg_match_all( $tag_pattern, $left_text, $left_tags, PREG_PATTERN_ORDER );
236243 $n = count( $left_slices);
237244
@@ -240,6 +247,7 @@
241248 */
242249 for ( $i=0 ; $i < $n - 1 ; $i++ ) {
243250 $str = $left_slices[$i];
 251+ $m = array();
244252 if ( preg_match("/(.*)<(p|dl)>/is", $str, $m ) ) {
245253 $left_slices[$i] = $m[1];
246254 $left_slices[$i+1] = substr( $str, strlen($m[1]) ) . $left_slices[$i+1];
@@ -254,6 +262,7 @@
255263 $stack = array();
256264 for( $i=0 ; $i < $n ; $i++) {
257265 $bits = preg_split( $this->tags, $left_slices[$i] );
 266+ $m = array();
258267 preg_match_all( $this->tags, $left_slices[$i], $m, PREG_SET_ORDER);
259268 $counter = 0;
260269 for($k=0 ; $k < count($m) ; $k++) {
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.image.php
@@ -105,6 +105,7 @@
106106
107107 wfProfileIn( 'tiffinfo' );
108108 wfDebug( __METHOD__ . ": $cmd\n" );
 109+ $retval = '';
109110 $dump = wfShellExec( $cmd, $retval );
110111 wfProfileOut( 'tiffinfo' );
111112
@@ -122,6 +123,7 @@
123124
124125 wfProfileIn( 'identify' );
125126 wfDebug( __METHOD__ . ": $cmd\n" );
 127+ $retval = '';
126128 $dump = wfShellExec( $cmd, $retval );
127129 wfProfileOut( 'identify' );
128130
@@ -153,6 +155,7 @@
154156
155157 wfProfileIn( 'exiv2' );
156158 wfDebug( __METHOD__ . ": $cmd\n" );
 159+ $retval = '';
157160 $dump = wfShellExec( $cmd, $retval );
158161 wfProfileOut( 'exiv2' );
159162
@@ -225,6 +228,8 @@
226229
227230 if ( $error ) continue;
228231
 232+ $m = array();
 233+
229234 if ( preg_match('/^TIFF Directory at offset 0x[a-f0-9]+ \((\d+)\)/', $row, $m) ) {
230235 # new IFD starting, flush previous page
231236
Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php
@@ -71,7 +71,7 @@
7272 // I ain't kidding... RecursiveIteratorIterator.
7373 foreach( new RecursiveIteratorIterator( $dirs ) as $pathname => $item ) {
7474 $filename = basename( $pathname );
75 -
 75+ $matches = array();
7676 if( preg_match( '/^(.*)\.i18n\.php$/', $filename, $matches ) ) {
7777 $group = $matches[1];
7878 $extFiles[$group] = $pathname;

Status & tagging log