r66639 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66638‎ | r66639 | r66640 >
Date:05:33, 19 May 2010
Author:mah
Status:ok
Tags:
Comment:
* remove function_exists calls for things that functions that always
exist under supported versions of PHP
** assert() is always defined for DifferenceEngine()
** mail() is always defined for UserMailer()
** is_executable() is defined for Windows from PHP 5.0.0 on
Modified paths:
  • /trunk/phase3/includes/Math.php (modified) (history)
  • /trunk/phase3/includes/UserMailer.php (modified) (history)
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -9,8 +9,6 @@
1010 // You may copy this code freely under the conditions of the GPL.
1111 //
1212
13 -define('USE_ASSERTS', function_exists('assert'));
14 -
1513 /**
1614 * @todo document
1715 * @private
@@ -153,8 +151,8 @@
154152 $edits = array();
155153 $xi = $yi = 0;
156154 while ($xi < $n_from || $yi < $n_to) {
157 - USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]);
158 - USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]);
 155+ assert($yi < $n_to || $this->xchanged[$xi]);
 156+ assert($xi < $n_from || $this->ychanged[$yi]);
159157
160158 // Skip matching "snake".
161159 $copy = array();
@@ -316,13 +314,13 @@
317315 while (list ($junk, $y) = each($matches))
318316 if (empty($this->in_seq[$y])) {
319317 $k = $this->_lcs_pos($y);
320 - USE_ASSERTS && assert($k > 0);
 318+ assert($k > 0);
321319 $ymids[$k] = $ymids[$k-1];
322320 break;
323321 }
324322 while (list ( /* $junk */, $y) = each($matches)) {
325323 if ($y > $this->seq[$k-1]) {
326 - USE_ASSERTS && assert($y < $this->seq[$k]);
 324+ assert($y < $this->seq[$k]);
327325 // Optimization: this is a common case:
328326 // next match is just replacing previous match.
329327 $this->in_seq[$this->seq[$k]] = false;
@@ -330,7 +328,7 @@
331329 $this->in_seq[$y] = 1;
332330 } else if (empty($this->in_seq[$y])) {
333331 $k = $this->_lcs_pos($y);
334 - USE_ASSERTS && assert($k > 0);
 332+ assert($k > 0);
335333 $ymids[$k] = $ymids[$k-1];
336334 }
337335 }
@@ -366,7 +364,7 @@
367365 $end = $mid;
368366 }
369367
370 - USE_ASSERTS && assert($ypos != $this->seq[$end]);
 368+ assert($ypos != $this->seq[$end]);
371369
372370 $this->in_seq[$this->seq[$end]] = false;
373371 $this->seq[$end] = $ypos;
@@ -446,7 +444,7 @@
447445 $i = 0;
448446 $j = 0;
449447
450 - USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)');
 448+ assert('sizeof($lines) == sizeof($changed)');
451449 $len = sizeof($lines);
452450 $other_len = sizeof($other_changed);
453451
@@ -466,7 +464,7 @@
467465 $j++;
468466
469467 while ($i < $len && ! $changed[$i]) {
470 - USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
 468+ assert('$j < $other_len && ! $other_changed[$j]');
471469 $i++; $j++;
472470 while ($j < $other_len && $other_changed[$j])
473471 $j++;
@@ -498,10 +496,10 @@
499497 $changed[--$i] = false;
500498 while ($start > 0 && $changed[$start - 1])
501499 $start--;
502 - USE_ASSERTS && assert('$j > 0');
 500+ assert('$j > 0');
503501 while ($other_changed[--$j])
504502 continue;
505 - USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
 503+ assert('$j >= 0 && !$other_changed[$j]');
506504 }
507505
508506 /*
@@ -524,7 +522,7 @@
525523 while ($i < $len && $changed[$i])
526524 $i++;
527525
528 - USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]');
 526+ assert('$j < $other_len && ! $other_changed[$j]');
529527 $j++;
530528 if ($j < $other_len && $other_changed[$j]) {
531529 $corresponding = $i;
@@ -541,10 +539,10 @@
542540 while ($corresponding < $i) {
543541 $changed[--$start] = 1;
544542 $changed[--$i] = 0;
545 - USE_ASSERTS && assert('$j > 0');
 543+ assert('$j > 0');
546544 while ($other_changed[--$j])
547545 continue;
548 - USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]');
 546+ assert('$j >= 0 && !$other_changed[$j]');
549547 }
550548 }
551549 wfProfileOut( __METHOD__ );
Index: trunk/phase3/includes/UserMailer.php
@@ -197,16 +197,12 @@
198198 ini_set( 'html_errors', '0' );
199199 set_error_handler( array( 'UserMailer', 'errorHandler' ) );
200200
201 - if (function_exists('mail')) {
202 - if (is_array($to)) {
203 - foreach ($to as $recip) {
204 - $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers );
205 - }
206 - } else {
207 - $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers );
 201+ if (is_array($to)) {
 202+ foreach ($to as $recip) {
 203+ $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers );
208204 }
209205 } else {
210 - self::$mErrorString = 'PHP is not configured to send mail';
 206+ $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers );
211207 }
212208
213209 restore_error_handler();
Index: trunk/phase3/includes/Math.php
@@ -56,7 +56,7 @@
5757 }
5858 }
5959
60 - if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) {
 60+ if( !is_executable( $wgTexvc ) ) {
6161 return $this->_error( 'math_notexvc' );
6262 }
6363 $cmd = $wgTexvc . ' ' .

Status & tagging log