From edc744dcd9886f914ba989a384bda1910b52f171 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Wed, 19 May 2010 05:33:27 +0000 Subject: [PATCH] * 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 --- includes/Math.php | 2 +- includes/UserMailer.php | 12 ++++-------- includes/diff/DifferenceEngine.php | 28 +++++++++++++--------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/includes/Math.php b/includes/Math.php index 3a06c5f96b..be8b87816b 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -56,7 +56,7 @@ class MathRenderer { } } - if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) { + if( !is_executable( $wgTexvc ) ) { return $this->_error( 'math_notexvc' ); } $cmd = $wgTexvc . ' ' . diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 5ae6c513e2..99f99d2ef3 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -197,16 +197,12 @@ class UserMailer { ini_set( 'html_errors', '0' ); set_error_handler( array( 'UserMailer', 'errorHandler' ) ); - if (function_exists('mail')) { - if (is_array($to)) { - foreach ($to as $recip) { - $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers ); - } - } else { - $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers ); + if (is_array($to)) { + foreach ($to as $recip) { + $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers ); } } else { - self::$mErrorString = 'PHP is not configured to send mail'; + $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers ); } restore_error_handler(); diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 184d1fc2c6..b13c726369 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -9,8 +9,6 @@ // You may copy this code freely under the conditions of the GPL. // -define('USE_ASSERTS', function_exists('assert')); - /** * @todo document * @private @@ -153,8 +151,8 @@ class _DiffEngine { $edits = array(); $xi = $yi = 0; while ($xi < $n_from || $yi < $n_to) { - USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]); - USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]); + assert($yi < $n_to || $this->xchanged[$xi]); + assert($xi < $n_from || $this->ychanged[$yi]); // Skip matching "snake". $copy = array(); @@ -316,13 +314,13 @@ class _DiffEngine { while (list ($junk, $y) = each($matches)) if (empty($this->in_seq[$y])) { $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); + assert($k > 0); $ymids[$k] = $ymids[$k-1]; break; } while (list ( /* $junk */, $y) = each($matches)) { if ($y > $this->seq[$k-1]) { - USE_ASSERTS && assert($y < $this->seq[$k]); + assert($y < $this->seq[$k]); // Optimization: this is a common case: // next match is just replacing previous match. $this->in_seq[$this->seq[$k]] = false; @@ -330,7 +328,7 @@ class _DiffEngine { $this->in_seq[$y] = 1; } else if (empty($this->in_seq[$y])) { $k = $this->_lcs_pos($y); - USE_ASSERTS && assert($k > 0); + assert($k > 0); $ymids[$k] = $ymids[$k-1]; } } @@ -366,7 +364,7 @@ class _DiffEngine { $end = $mid; } - USE_ASSERTS && assert($ypos != $this->seq[$end]); + assert($ypos != $this->seq[$end]); $this->in_seq[$this->seq[$end]] = false; $this->seq[$end] = $ypos; @@ -446,7 +444,7 @@ class _DiffEngine { $i = 0; $j = 0; - USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); + assert('sizeof($lines) == sizeof($changed)'); $len = sizeof($lines); $other_len = sizeof($other_changed); @@ -466,7 +464,7 @@ class _DiffEngine { $j++; while ($i < $len && ! $changed[$i]) { - USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + assert('$j < $other_len && ! $other_changed[$j]'); $i++; $j++; while ($j < $other_len && $other_changed[$j]) $j++; @@ -498,10 +496,10 @@ class _DiffEngine { $changed[--$i] = false; while ($start > 0 && $changed[$start - 1]) $start--; - USE_ASSERTS && assert('$j > 0'); + assert('$j > 0'); while ($other_changed[--$j]) continue; - USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + assert('$j >= 0 && !$other_changed[$j]'); } /* @@ -524,7 +522,7 @@ class _DiffEngine { while ($i < $len && $changed[$i]) $i++; - USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + assert('$j < $other_len && ! $other_changed[$j]'); $j++; if ($j < $other_len && $other_changed[$j]) { $corresponding = $i; @@ -541,10 +539,10 @@ class _DiffEngine { while ($corresponding < $i) { $changed[--$start] = 1; $changed[--$i] = 0; - USE_ASSERTS && assert('$j > 0'); + assert('$j > 0'); while ($other_changed[--$j]) continue; - USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + assert('$j >= 0 && !$other_changed[$j]'); } } wfProfileOut( __METHOD__ ); -- 2.20.1